I have the requirement to find the difference between two record values of a record type like we do in case of cdts using cdtdifference(). I have the previous value of record type and then new value, I need to populate Audit table using these difference values.
Any function like cdtdifference() or any workaround to do this?
Discussion posts and replies are publicly visible
Any suggestions for this, we need it for the same purpose
There's this plugin:
But you can also do the same with a!forEach that iterates over the attributes (using a!keys) on the CDT or Record.
What I propose is:
sreesudhakasibatla I also achieved my requirement using the method Ignacio Morán suggested. There is no direct function to compare records.
Correct, I wanted to know if there is a direct function like this for records. But seems like there is none. Will convert it to CDT and then use it.
Record Events might be an option as well.
Thanks for your responses.Appreciate it.
There is no purpose built function but it's pretty easy to do with code:
a!localVariables( local!oldEntity: a!map( firstName: "John", lastName: "Smith", age: "23" ), local!newEntity: a!map( firstName: "Jane", lastName: "Smith", age: "24" ), reject( a!isNullOrEmpty, a!forEach( items: a!keys(local!oldEntity), expression: a!localVariables( local!oldValue: index(local!oldEntity, fv!item, null), local!newValue: index(local!newEntity, fv!item, null), if(local!oldValue <> local!newValue, { fieldName: fv!item, oldValue: local!oldValue, newValue: local!newValue }, null ) ) ) ) )
Great, Thank you