Hi All,
Can you guys please help how do I get list of Ids containing duplicates values in list of objects containing duplicate values. The list always has duplicate values.
This is the list
locallist: {
{ id:12, FacilityName:"New Test1", FacilityTypeId:8,},
{ id:13, FacilityName:"New Test0", FacilityTypeId:9,},
{ id:14, FacilityName:"New Test1", FacilityTypeId:8,},
{ id:15, FacilityName:"New Test0", FacilityTypeId:9,},
}
what I want to get list of ids containing duplicates. So in this case, id 12, 14 are duplicate having same FacilityName, FacilityTypeId. And id 13, 15 are duplicate having same FacilityName, FacilityTypeId
local!ResultList: { { 12, 14 }. {13,15} }
Any help would be appreciated
Discussion posts and replies are publicly visible
a!localVariables( local!list: { {id: 12, FacilityName: "New Test1", FacilityTypeId: 8}, {id: 13, FacilityName: "New Test0", FacilityTypeId: 9}, {id: 14, FacilityName: "New Test1", FacilityTypeId: 8}, {id: 15, FacilityName: "New Test0", FacilityTypeId: 9} }, local!withKey: a!forEach( items: local!list, expression: a!map( id: fv!item.id, key: fv!item.FacilityName & "-" & fv!item.FacilityTypeId ) ), local!uniqueKeys: union(local!withKey.key, local!withKey.key), a!forEach( items: local!uniqueKeys, expression: a!localVariables( local!matchingIds: tointeger(local!withKey[wherecontains(fv!item, local!withKey.key)].id), if(count(local!matchingIds) > 1, local!matchingIds, {}) ) ) )
Sure, Thank so much giving me the implementation. The result I got is {12, 14, 13, 15}. Is there a way I can get { {12, 14}, {13,15} }. Want to let the user know specifically that {12,14} and {13, 15} are duplicates?
Appian will always flatten nested lists.
Is there a way to not flatten the list in this case. Or its not possible
I think I found a way by using the toString function under for loop expression to return the list of strings as opposed to list of list. Thanks everyone!!