I have two values consider type is CDT: local!oldData: {customer: "oldCustomer",location:"Hyd",supplier: "ABC"},local!updatedData: {customer: "newCustomer",location: "Hyd",supplier: "DEF"}I want to give response only the updated values like follows:fieldName: customeroldValue: oldCustomer,newValue: newCustomer,fieldName: supplier,oldValue: ABC,newValue: DEFCan anyone please help me to build logic for it.
Discussion posts and replies are publicly visible
The a!keys() function gives you the list of keys in your dictionary. Use a foreach to loop on that list and compare the two values from each dictionary. Pretty straight forward...
Give it a try and come back when you have something working.
a!localVariables( local!oldCargo: cast( typeof( 'type!{urn:com:appian:types:peg:car}PEG_CAR_Cargo'() ), rule!PEG_CAR_QRY_getCargo(cargoIds: ri!cargoId) ), local!newCargo: cast( typeof( 'type!{urn:com:appian:types:peg:car}PEG_CAR_Cargo'() ), index(ri!formattedData, "Cargo", null) ), local!updatedFields: a!keys(local!newCargo), a!forEach( local!updatedFields, a!localVariables( local!field: fv!item, local!oldValue: local!oldCargo[local!field], local!newValue: local!newCargo[local!field], if( local!oldValue <> local!newValue, a!map( "fieldName": local!field, "oldValue": local!oldValue, "newValue": local!newValue ), null ) ) ) )
Glad to help @Shukur Shake :)