As you know Query Rule has been deprecated in newer versions of Appian. I need a function that will mimic the exact behaviour of Query rule including the return type.
I have tried using queryEntity() but the return type is not the same as query rule so i am facing a lot of issues.
If you want to return the same data type, then you need to add as well the cast() function.
The default output format of a queryentity is a datasubset, in order to get the data in the same format of a query rule, you can try to slice the data part of the query entity result. You can either use the index function like index(local!output,"data",null) or just local!output.data. This would give you a dictionary type object. You can directly use in a CDT type rule input.As mentioned below by ManuelHTG you can use cast on top of the result set if you need to convert the output to a specific cdt.Also query rules used to return all the columns whereas queryentity only returns specific columns, this can be achieved by not passing any query selection parameter to the queryentity.
Keep in mind also that traditional query rules will pass back a "dataSubset" type whenever pagingInfo is passed in.
Given this, I've previously set up a standard QE recipe which I usually make a new version of for each CDT i might be querying. In that QE expression rule, I run the query entity as normal (using the passed-in pagingInfo if it was given, and a generic set otherwise); then I return the whole dataSubset if the pagingInfo was provided, and return just the ".data" result from the query entity otherwise.
Note that this does return basically an "any type" dictionary instead of a type-cast CDT. I've almost never had an issue with this - it does mean that a very few things need to be manually typecast when these are used. You could take the subsequent step of typecasting your ".data" output as the CDT type, but this creates its own issues (such as, if the QE returns a selected set of columns instead of all columns).
What exactly is your use case for needing the exact return type? What issues is this causing?
Discussion posts and replies are publicly visible
© 2020 Appian. All rights reserved.