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
13 replies
Subscribers
8 subscribers
Views
4816 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi Everyone, We are seeing some strange behavior when we are populati
brettr
over 9 years ago
Hi Everyone,
We are seeing some strange behavior when we are populating a grid using a queryEntity inside of the with instead of a todatasubet. If we sort on a column that has all of the same data on the first page, and the same data on a couple rows on the second page, there are some rows that are never actually displayed on the grid. Our current theory is that this is occurring because there is no secondary sort field with a queryEntity, and the videos that I will link to later seem to support that. It looks like a query rule will have a secondary sort based on the "Sort query results by" configuration in the query rule itself if you change the pagingInfo.sortInfo that is passed into the query rule. Unfortunately, a queryEntity actually breaks if you pass it a pagingInfo that has an array of sortInfo, so I do not see a way to define, or force, a secondary sort field. According to documentation, it looks like sorting on multiple colum...
OriginalPostID-177486
OriginalPostID-177486
Discussion posts and replies are publicly visible
0
brettr
over 9 years ago
...ns is not supported on a queryEntity.
The below video shows a queryEntity retrieving data based on the pagingInfo saved in the grid (selecting 'Procurement Organization' to sort on). All of this is done inside a with():
screencast.com/.../hZ1e0My66IhV
The below video shows a query rule, with a default sort of 'Procurement Identifier', retrieving data based on the pagingInfo saved in the grid (selecting 'Procurement Organization' to sort on). All of this is done inside a with():
screencast.com/.../ZHI3dKXJEFUl
It looks like the query rule correctly displays all data without repeating while paging through it. We are not able to actually use a query rule in practice, because we require dynamic filters based on inputs. And unfortunately, we are not able to return all of the data to run it through a todatasubset because of the amount of data that would be returned. Has anyone run into this issue before with a queryEntity, and have you been able to resolve it...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
brettr
over 9 years ago
...?
Thanks in advance!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
nickq
over 9 years ago
If I've understood you correctly, you need to sort on multiple fields via a query entity. Try taking the output of the query entity and doing a fn!todatasubset on it, and pass your sort array into its pagingInfo. Ex:
local!datasubset: todatasubset(
local!QE_Result.data,
a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: {
local!sortArray
}
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
brettr
over 9 years ago
Unfortunately, we can't take this approach, because the set of data that would be returned is too large. That is why we pass a batchSize of 10 into the query.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
nickq
over 9 years ago
Have you tried making the database do the work and setting up some order by clauses?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
brettr
over 9 years ago
Unfortunately, it does not look like that works either :/
I thought it would, but I am getting the exact same sorting when I actually click the 'Procurement Organization' column.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Andrew P Gramann
Certified Lead Developer
over 9 years ago
I've seen this occasionally if you try to sort on a field that is not unique.
It's not ideal, but you could wrap your entity in a view that returns 2 columns for every field that is displayed in your grid that is not unique. For the duplicate column, append the primary key to the columns's actual value. You can then use this duplicate field as the "field" parameter in your paging grid's columns configurations (ensuring that any sorting is done on a unique column) and keep the original field for the values that you will display.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Tim
Certified Lead Developer
over 9 years ago
It's an interesting one, possible caused by the low cardinality of your sort field and the chaotic order of data that gets returned from an RDBMS when the sort field has such values. I've tested multiple a!sortInfo in a!queryEntity on 7.11 and it works but this will obviously be overwritten when clicking on a column heading.
Here's something funky you could try, when clicking on the column heading you could append an additional sort column (such as the primary key field) to your paginginfo so that you always have multiple column sorting in your grid.
Below are the value and saveInto attributes of your gridField:
value: local!pagingInfo,
saveInto: {
local!pagingInfo,
a!save(
local!pagingInfo.sort,
append(
save!value.sort,
a!sortInfo(
field: "<your PK field>",
ascending: true
)
)
)
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
brettr
over 9 years ago
Andrew, thank you, that seems like it could be a possibility. I am going to give this a shot, but I have a feeling we won't be able to do this because it will almost double the already large set of data that we have. Thanks for the suggestion, I will let you know how it goes!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
brettr
over 9 years ago
Tim, I should have mentioned that we are currently on 7.8, but migrating to 7.11 in the near future. We have actually tried this before, and the queryEntity will break because it does not support a pagingInfo that has an array of sortInfos.
Does a queryEntity accept multiple sortInfos in 7.11? I am looking at documentation, and it still looks like sorting on multiple fields is not supported for a queryEntity.
forum.appian.com/.../Querying_Data_From_an_RDBMS.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>