Re: Generic code for entity selection projection
Hi Steve, A couple of things to consider. You mention working with an 'entity selection' but then get into talking about collections. To create a collection from an entity selection, or only some properties of it, take a look at .toCollection(). https://doc.4d.com/4Dv18R3/4D/18-R3/entitySelectiontoCollection.305-4900500.en.html This might give you want you want right there as you pass a comma delimited string to the method. The other approach is to simply do a query for what you need. These are really fast in ORDA thanks to a lot of optimization built in and it's very flexible. https://doc.4d.com/4Dv18R3/4D/18-R3/dataClassquery.305-4900853.en.html The old way of approaching these sorts of situations where you paid a big performance hit for multiple searches isn't nearly so true now. But it depends on your data. Try it and see. On Mon, May 11, 2020 at 9:04 PM Steve Slanec via 4D_Tech < 4d_tech@lists.4d.com> wrote: > I'm trying come up with generic code that produces a projection from an > entity selection, and I think must be missing something obvious. I’d like > to perform the following statement: > > $collection:=$employees.company.country > > But as generic code. I want to be able to pass the ORDA path > “company.country” as a text variable so that I can change it at runtime. > > Obviously, using square bracket notation doesn’t work because square > brackets for entity selections are used for indexes: > > $collection:=$employees[“company.country”] // Syntax error > > So how can I do this? > > I guess I could write a method that splits the ORDA path into tokens, > examines each token individually, and traverses through relations if the > token kind is a “relation" until we get to the last token, whose kind must > be “storage". But I’m hoping I’m just being ignorant - it seems like a lot > of work for doing what object notation does so simply and elegantly. > > Using 4D v18, macOS 10.14 > > Thanks for any advice! > > - Steve > > > > Steve Slanec > Slanecon Digital > > ** > 4D Internet Users Group (4D iNUG) > New Forum: https://discuss.4D.com > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** -- Kirk Brooks San Francisco, CA == ** 4D Internet Users Group (4D iNUG) New Forum: https://discuss.4D.com Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
RE: Generic code for entity selection projection
Steve, One way to do it is a bit convoluted, but will do what you want: $Params:=split string($YourText;".") Case of :($Params.length=1) $collection:=$employees[$Params[0]] :($Params.length=2) $collection:=$employees[$Params[0]] [$Params[1]] :($Params.length=3) $collection:=$employees[$Params[0]] [$Params[1]] ]] [$Params[2]] :($Params.length=4) $collection:=$employees[$Params[0]] [$Params[1]] ]] [$Params[2]] ]] [$Params[3]] End case Not pretty, but effective... Cheers, Lahav -Original Message- From: 4D_Tech <4d_tech-boun...@lists.4d.com> On Behalf Of Steve Slanec via 4D_Tech Sent: Monday, May 11, 2020 10:04 PM To: 4d_tech@lists.4d.com Cc: Steve Slanec Subject: Generic code for entity selection projection I'm trying come up with generic code that produces a projection from an entity selection, and I think must be missing something obvious. I’d like to perform the following statement: $collection:=$employees.company.country But as generic code. I want to be able to pass the ORDA path “company.country” as a text variable so that I can change it at runtime. Obviously, using square bracket notation doesn’t work because square brackets for entity selections are used for indexes: $collection:=$employees[“company.country”] // Syntax error So how can I do this? I guess I could write a method that splits the ORDA path into tokens, examines each token individually, and traverses through relations if the token kind is a “relation" until we get to the last token, whose kind must be “storage". But I’m hoping I’m just being ignorant - it seems like a lot of work for doing what object notation does so simply and elegantly. Using 4D v18, macOS 10.14 Thanks for any advice! - Steve Steve Slanec Slanecon Digital ** 4D Internet Users Group (4D iNUG) New Forum: https://discuss.4D.com Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com ** ** 4D Internet Users Group (4D iNUG) New Forum: https://discuss.4D.com Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Generic code for entity selection projection
I'm trying come up with generic code that produces a projection from an entity selection, and I think must be missing something obvious. I’d like to perform the following statement: $collection:=$employees.company.country But as generic code. I want to be able to pass the ORDA path “company.country” as a text variable so that I can change it at runtime. Obviously, using square bracket notation doesn’t work because square brackets for entity selections are used for indexes: $collection:=$employees[“company.country”] // Syntax error So how can I do this? I guess I could write a method that splits the ORDA path into tokens, examines each token individually, and traverses through relations if the token kind is a “relation" until we get to the last token, whose kind must be “storage". But I’m hoping I’m just being ignorant - it seems like a lot of work for doing what object notation does so simply and elegantly. Using 4D v18, macOS 10.14 Thanks for any advice! - Steve Steve Slanec Slanecon Digital ** 4D Internet Users Group (4D iNUG) New Forum: https://discuss.4D.com Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Discuss.4D.com - old Safari doesn't work (is known?)
I have gotten as far as receiving a summary of new posts on the new forum (that’s good because I get/got the iNUG digest). But, when I click on the new summary topic link, Safari 10.1.2 (yeah, I know it’s old) rejects it with “...can’t establish secure connection…”. Firefox v76.0.1 does work if you drag a link over onto that, but it won't remember your last login address/password - a bit annoying that… Cheers, Keith ** 4D Internet Users Group (4D iNUG) New Forum: https://discuss.4D.com Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **