When using a!queryEntity() to retrieve CDT objects from a table according to a filter, I have noticed that it reverses the order of columns/CDT fields.Is there any way to prevent this? Why is this happening?
I know what you mean, though to be exact the apparent "order" in a dictionary very often makes no difference.
FYI, if it's important to you in a particular instance, you can always cast the query result as the CDT type and then your dictionary will not only have the correct type and order, but also the various members will be the correct type also. Just do so carefully, i've seen instances where this technique is overused with no good reason and it ends up becoming confusing.
Thank you! This has been very helpful. Do you know why the query doesn't automatically return an output of type "list of CDT"?
It doesn't return it as a list of CDT because it makes it more clear what information was returned by the query. For example, let's suppose you set up a query that returns only two fields: id and name, even though your source CDT had 20 fields. Then you cast the result to CDT and save this result as an expression rule. If I now use this rule inside of an interface or elsewhere in Appian, it will return the list of CDT with only ID and name returned. However, now it isn't as clear - did my query only return those two fields or are all the other fields null in the database?
Returning a dictionary makes this simpler because now I know exactly what fields are returned from my query. Plus, as the previous poster mentioned, you can always cast the result to CDT if you need it.
Discussion posts and replies are publicly visible
© 2020 Appian. All rights reserved.