For accessing the next and previous records from the summary page view i have been applying the following logic on primary key and its giving me the required result of giving the previous and last records correctly.
a!queryEntity( entity: cons!TT_TimesheetLog_Cons, query: a!query( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 1, sort: a!sortInfo( field: "id", ascending: if(ri!fetchingPrevious, false(), true()) ) ), filter: a!queryFilter( field: "id", operator: if(ri!fetchingPrevious, "<", ">"), value: ri!currentPrimaryKey ) )).data.id
now the situation is following:
-like the next and previous buttons, I also want the last and first buttons which should take me to the first and last records in the grid, e.g. if i have 100 records the first button should open the first record summary view tab and the last button should open the 100th record. Currently I am not able to do that.
-also if i am on the last record lets say 100 i want the last button to be disabled in that scenario, similarly if i am on first record i want the first button to be disabled.
How can i achieve these two functionalities?
Discussion posts and replies are publicly visible
When you want to open the first record, simply pass the operator as "=", start index as 1. Done. When you want to open the last record, pass the operator as "=", the startIndex as the total count from the query, or sort the data descending and pass the start index as 1.
can you show it with some exmaple?
a!queryEntity( entity: cons!TT_TimesheetLog_Cons, query: a!query( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 1, sort: a!sortInfo( field: "id", ascending: if( or(ri!fetchingPrevious, ri!position = "LAST"), false(), true() ) ) ), filter: a!queryFilter( field: "id", operator: if( or(ri!position = "FIRST", ri!position = "LAST"), "=", if(ri!fetchingPrevious, "<", ">") ), value: ri!currentPrimaryKey ) ) ).data.id
it gives the current primary key in both situations of "First" and "Last" positions.
Oh. I missed one thing. Try now.
a!queryEntity( entity: cons!TT_TimesheetLog_Cons, query: a!query( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 1, sort: a!sortInfo( field: "id", ascending: if( or(ri!fetchingPrevious, ri!position = "LAST"), false(), true() ) ) ), filter: a!queryFilter( field: "id", operator: if(ri!fetchingPrevious, "<", ">"), value: ri!currentPrimaryKey, applyWhen: a!isNullOrEmpty(ri!position) ) ) ).data.id
its working fine now.can you explain its logic please. from me i assume that its accessing the first index due to "start index" being given as 1 but how its accessing the "Last" index? is their "Last" a keyword for last index in appian? thanks
Nope. Once you retrieve the data in descending order, then the first record is basically the last record. If you look at the 10th row, there is a condition that if position="LAST" then we're fetching the data in descending order. Also, if it worked, please consider accepting the answer so other people can find the right answer if they are facing the same problem and other contributors do not invest their time in providing solutions.