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
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