[SOLVED] LIST_LINE example seems bogus. Can't work

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

[SOLVED] LIST_LINE example seems bogus. Can't work

Post by Jaymer »

Example from 8.2 Docs PDF

Code: Select all

<<LIST_LINE(Client.Children,’ORDER BY Child.FirstName DESC‘,‘ ‘,’,’,‘FirstName’, ‘LastName’, ‘Age,#’)>>
Example from Java hint popup in 8.2

Code: Select all

LIST_LINE(Client.Children,'ORDER BY Client.Name DESC',',',', ','FirstName', 'LastName','Age')
PROBLEM
1. part of the problem is that the Docs tradiationally have bad Typos - which cause frustration when you copy/paste code and it won't event syntax check. then there's the issue with the ` marks vs '

2. I don't think thats an issue here. I was using the online tool hint (tap F4) - this example doesn't even make sense. Why would you generate this long string of each of the kids, sorted by the name of mother or father (Client.Name is not even a field in the Client.Children table_? UNLESS, the word Children is meant to mean "child recs of a parent record" and not actual biological units and its not meant to be a real example, only figurative. I dunno.

In either case this is wrong... and I can't figure it out.
This example is supposed to print a list of kids... all the kids that are in a reference table (Children) for a given Client record.

3. this COULD be a possibility:

Code: Select all

LIST_LINE(Client.pm_Children,'ORDER BY Client.pm_Children.FirstName DESC',',',', ','FirstName', 'LastName','Age')
a) added pm_ to help distinguish thats its a list and not just a regular field
b) changed to Client.pm_Children.FirstName because you want the list of kids' names sorted

4. This works, but the customer is going to ask "Why are they not in order?"
My list came out: SALT LAKE CITY, MACON, ATLANTA, PITTSBURGH, PHILADELPHIA

Code: Select all

RegularUser.CanOrderFor = LIST_LINE(RegularUser.pm_OrderAffils  ,',',', ','ShortName')
Now, if you want it to be sorted A-Z, the HINT (which is incorrect) implies this:

Code: Select all

RegularUser.CanOrderFor = LIST_LINE(RegularUser.pm_OrderAffils, 'ORDER BY RegularUser.pm_OrderAffils.ShortName ASC'   ,',',', ','ShortName') 
Creates this string: RICHMOND, SALT LAKE CITY, MACON, PITTSBURGH, PHILADELPHIA
Which isn't even sorted by ID. this is from Tomcat output after the SAVE: Mast_Cust:200078@PHILADELPHIA|Mast_Cust:200079@PITTSBURGH|Mast_Cust:200068@MACON|Mast_Cust:200086@SALT LAKE CITY|Mast_Cust:200083@RICHMOND
Macon shud be in front if its by ID, and its not Alpha sort. Doesn't really matter what it is, its NOT what was specified.

5. So, last resort, try the QUERY option... because in the Query I could specify an ORDER BY - I'll get this sucker !!!!

<testing now>

jaymer...
Last edited by Jaymer on Tue Jun 11, 2019 8:04 pm, edited 1 time in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: LIST_LINE example seems bogus. Can't work

Post by Jaymer »

SOLUTION

Code: Select all

IF Mast_Cust WAS ADDED TO RegularUser.pm_OrderAffils OR
Mast_Cust WAS REMOVED FROM RegularUser.pm_OrderAffils THEN
RegularUser.CanOrderFor = LIST_LINE('FIND Mast_Cust WHERE Mast_Cust IN RegularUser.pm_OrderAffils 
ORDER BY Mast_Cust.ShortName ASC'   ,',',', ','ShortName') 
The Query option threw me for a while... I was trying to reference a SAVED QUERY.
I could have used the "short form" if I didn't need the results sorted - but can't think when I would want a list in a random order.

--> jaymerTip
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: [SOLVED] LIST_LINE example seems bogus. Can't work

Post by hpl123 »

Thanks Jaymer for writing the solution and support please update the documentation so the syntax etc. is correct. The stated example in the docs does not work.
Henrik (V8 Developer Ed. - Windows)
Post Reply