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
+1
person also asked this
people also asked this
Replies
10 replies
Subscribers
8 subscribers
Views
5820 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
Is it possible to use a!sortInfo to sort by field1 and then by field2?
cherylr
over 9 years ago
Is it possible to use a!sortInfo to sort by field1 and then by field2?
I tried the following code, but I am getting an error " Invalid Cast: Cannot cast from type 'PagingInfo' to type 'Date': CastInvalid"
a!sortInfo({
{field:"field1",ascending:false)},
{field:"field2",ascending:false)}
})
OriginalPostID-141868
OriginalPostID-141868
Discussion posts and replies are publicly visible
0
Conor Cahill
Certified Lead Developer
over 9 years ago
You'll create multiple a!sortInfo() to do this. In the pagingInfo's "sort" field put the following:
sort: {
a!sortInfo(field: "field1", ascending: false),
a!sortInfo(field: "field2", ascending: false)
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
cherylr
over 9 years ago
Thanks. Now I am getting a new error, "Error evaluating function 'queryrecord' : Cannot sort by multiple fields."
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Conor Cahill
Certified Lead Developer
over 9 years ago
The queryrecord() cannot do multiple sorts, but you can wrap that function in a todatasubset(), which will take multiple sorts. Remove the sorting from your queryrecord and put it in the 'pagingInfo' field in the todatasubset().
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
cherylr
over 9 years ago
Thanks!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sariqs
over 9 years ago
Putting multiple sort on todatasubset will not help to get records sorted correctly as todatasubset() does operation on already fetched data which is in memory and I guess multiple sort should be done on actual database table/entity directly rather than already fetched data.
In my case I need to have data sorted based on multiple fields from a table having 1000s of records and my paging size is 10 only. In this case putting multiple sorts on todatasubset wont help, please correct me on this.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Conor Cahill
Certified Lead Developer
over 9 years ago
If you are getting the data from a database table you can pass a pagingInfo into the query rule that contains your multiple sorts.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sariqs
over 9 years ago
Thanks for your response.
I am using queryentity function and getting the error can not sort on multiple fields. So its not possible with queryentity but only with queryrule ?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sariqs
over 9 years ago
Ok here it mentions clearly that query rule only supports multiple field sorting.
forum.appian.com/.../Querying_Data_From_an_RDBMS.html
Unfortunately in my case I need do have complex conditions along with multiple field sorting.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Conor Cahill
Certified Lead Developer
over 9 years ago
You could run the queryEntity without sorting, and then push that through a todatasubset(), applying the sorting. Depending on the size of your dataset this may be a slow way to do what you want.
You could also add a column that is some sort of combination of the multiple columns you want to sort by (e.g. column1.column2), and then sorting by only this new column will essentially sort by column1 then column2.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sariqs
over 9 years ago
I will try second approach by binding a view with another CDT where multiple columns merged in one to do sorting in a way I want.
Thanks for your help on this much appreciated.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel