Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
10 replies
Subscribers
6 subscribers
Views
5650 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Process
Hi, I am trying to sort a text array and tried using the following recipe.
Howard
over 10 years ago
Hi,
I am trying to sort a text array and tried using the following recipe.
forum.appian.com/.../Function_Recipes.html
Since this is just an array, not a record type, I am not sure what to put in as the field name to sort on in the data input tab. When I try to put in "field" as the value, I get an error evaluating expression. Any ideas? Thanks.
An error occurred while evaluating expression: departmentNameList:todatasubset(#"_a-0000d27e-8161-8000-8fc8-0a000064044c_72737",ac!pagingInfoNodeInput2).data (Expression evaluation error at function 'todatasubset': Error evaluating function 'todatasubset' : java.lang.IllegalArgumentException: The given data type is not a record type...
OriginalPostID-124071
OriginalPostID-124071
Discussion posts and replies are publicly visible
Top Replies
Mike James
over 10 years ago
+1
Certified Lead Developer
The sorttextarray() function is part of the Sort Utilities Plugin: forum.appian.com/.../summary
Parents
0
Dan Lluhi
Certified Lead Developer
over 10 years ago
Strange, it works fine when I run it. However, I am using 7.5, so that might be the difference. Looking at the documentation for todatasubset at
forum.appian.com/.../Scripting_Functions
it says that the first parameter (arrayToPage) can use dictionary syntax, which is what is happening in my example above. However it does say towards the end "Sorting is only supported for complex data types and is not supported for a dictionary array." which is probably what is causing the error you are seeing. If that's the case, I'm not sure how it works for me, but there is another workaround you could try.
Instead, create a CDT for this purpose specifically, which only has one field (a text field to store the text value you want to sort). and instead of returning {field: ri!text} in rule!toCDT to create a dictionary, return type!yourCDT(field: ri!text) to create an instance of this new CDT. Alternatively, if you dont want to create a new CDT, you could use an existing CDT that has a text field. For example, if you had an Employee CDT with a field for "name", you could define rule!toCDT as :
type!Employee(name: ri!text), and change the rest of the code to the following:
load(
local!textArray: {
"b",
"a"
},
local!tempCDT: apply(
rule!toCDT,
local!textArray
),
local!pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: a!sortInfo(
field: "name",
ascending: true
)
),
todatasubset(
local!tempCDT,
local!pagingInfo
).data.name
)
Hope this helps!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Dan Lluhi
Certified Lead Developer
over 10 years ago
Strange, it works fine when I run it. However, I am using 7.5, so that might be the difference. Looking at the documentation for todatasubset at
forum.appian.com/.../Scripting_Functions
it says that the first parameter (arrayToPage) can use dictionary syntax, which is what is happening in my example above. However it does say towards the end "Sorting is only supported for complex data types and is not supported for a dictionary array." which is probably what is causing the error you are seeing. If that's the case, I'm not sure how it works for me, but there is another workaround you could try.
Instead, create a CDT for this purpose specifically, which only has one field (a text field to store the text value you want to sort). and instead of returning {field: ri!text} in rule!toCDT to create a dictionary, return type!yourCDT(field: ri!text) to create an instance of this new CDT. Alternatively, if you dont want to create a new CDT, you could use an existing CDT that has a text field. For example, if you had an Employee CDT with a field for "name", you could define rule!toCDT as :
type!Employee(name: ri!text), and change the rest of the code to the following:
load(
local!textArray: {
"b",
"a"
},
local!tempCDT: apply(
rule!toCDT,
local!textArray
),
local!pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: a!sortInfo(
field: "name",
ascending: true
)
),
todatasubset(
local!tempCDT,
local!pagingInfo
).data.name
)
Hope this helps!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data