local!data: { a!map(SAPNumber: "1111111", Qty: "1", Spare: "0"), a!map(SAPNumber: "1111111", Qty: "2", Spare: "1"), a!map(SAPNumber: "1111111", Qty: "3", Spare: "0"), a!map(SAPNumber: "2222222", Qty: "1", Spare: "0") },
In the above list, If a duplicate combination of 'SAPNumber' and 'Spare' exists in the list, display a message indicating that duplicate data is present.
Example :
a!map(SAPNumber: "1111111", Qty: "1", Spare: "0"),
a!map(SAPNumber: "1111111", Qty: "3", Spare: "0"),
here, 'SAPNumber' and 'Spare' are same so it must shows a message.
Discussion posts and replies are publicly visible
A simple approach is to create a list of combined keys, get the unique combined keys, and then compare the number of combined keys to the number of items in your list. Below the code:
a!localVariables( local!data: { a!map(SAPNumber: "1111111", Qty: "1", Spare: "0"), a!map(SAPNumber: "1111111", Qty: "2", Spare: "1"), a!map(SAPNumber: "1111111", Qty: "3", Spare: "0"), a!map(SAPNumber: "2222222", Qty: "1", Spare: "0") }, local!combinedKey: a!forEach( items: local!data, expression: concat(fv!item.SAPNumber, "-", fv!item.Spare) ), if( count(local!data) <> count(union(local!combinedKey, local!combinedKey)), "Validation Message", "" ) )