Hi All,
I have a query if we have two array one is local!finalGridData and second one is local!origionalData.
In the local!finalgridData i have updated data
local!finalGridData containing data like-
1. id:1, enddate: 21/01/2025 ,
id:1, endDate: 20/01/2025,
id: 1, endDate: 19/01/2025
2. id:2, enddDate: 17/01/2025,
id:2,enddate:15/01/2025
local!origionalData containing data like-
1. id:1, enddate: 15/01/2025 ,
id:1, endDate: 16/01/2025,
id: 1, endDate: 14/01/2025
now we can see in local!finalGridData i have some updated data with endDate , but it also have data for id:2 which is not updated.
so i want to fetch only updated data from local!finalGridData .
in this scenario id:2 data is not updated but in some cases it will update if user updated the date from UI .
if both ids data updated then it's ok to send all the data but if not for all ids then i have to send only updated data in submit button.
so please anyone can help me on this.Thanks in advance
Discussion posts and replies are publicly visible
What did you try so far? I mean, this is not more than a foreach() on the your final data, and a condition to either include or exclude the data from the resulting list.
Hi Stefan Helzle,
i have tried this, but it's not working
a!save(local!test, a!forEach( items: local!finalgridData, expression: if( fv!item.endDate=index(local!originalData.data, wherecontains(touniformstring(fv!item.endDate), touniformstring(local!originalData.data.endDate)),{}).endDate, remove(fv!item, index(local!originalData, wherecontains(touniformstring(fv!item.referenceNumber),touniformstring(local!originalData.data.referenceNumber), ),{})), fv!item )), )
That condition looks plausible, but what do you try to do with that remove()?
i am trying to remove those ids which are not updated in finalgriddata.
Sure, but remove does not do that. It removes an item from a list by its index. You do not pass the list, but the item you iterate on.
Find an example here: https://docs.appian.com/suite/help/24.4/Function_Recipes.html#extract-a-list-from-an-entitydata-array-of-the-data-written-to-a-single-entity
thanks i am trying with given use case.
HI madhup0003 ,
As per my understanding you need only the data that is modified to store. You can use the difference() to get the modified data.
The below code might help.
a!localVariables( local!options:{"Yes","No"}, local!originalGridData:a!refreshVariable( value: { a!map(id:"1",date:date(2025,1,15)), a!map(id:"1",date:date(2025,1,16)), a!map(id:"1",date:date(2025,1,14)), a!map(id:"2",date:date(2025,1,17)), a!map(id:"2",date:date(2025,1,15)), }, refreshOnReferencedVarChange: false() ), local!changedData, local!finaldata:local!originalGridData, { a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label:"Id"), a!gridLayoutHeaderCell(label:"Date"), }, columnConfigs: { a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), }, rows: a!forEach( items: local!finaldata, expression: a!gridRowLayout( contents: { a!textField( value: fv!item.id, saveInto: fv!item.id ), a!dateField( value: fv!item.date, saveInto: fv!item.date ) } ) ), ), a!buttonArrayLayout( buttons: { a!buttonWidget( label:"Save", saveInto: { a!save(local!changedData,difference(local!finaldata,local!originalGridData)) } ) } ), /*Changed data*/ a!gridField( data: local!changedData, columns: { a!gridColumn( label:"Id", value: fv!row.id ), a!gridColumn( label:"Date", value: fv!row.date ) }, borderStyle: "STANDARD" ) } )
thanks JayaPrakash Ravipati
yes i need only that data which is modified in local!finalGirddata, but i can't use grid for that even difference will not work
Can you elaborate your scenario some more and you are trying it in interface or expression rule.
difference will work