Remove duplicates from array: Difference between revisions
Jump to navigation
Jump to search
Created page with "Example how to build an array of persons and in the end filter out the duplicates <nowiki> var returnRequest = #1#; var allActors = JSON.parse(CommonInterface.callWebservice..." |
No edit summary |
||
Line 1: | Line 1: | ||
Example how to build an array of persons and in the end filter out the duplicates | Example how to build an array of persons and in the end filter out the duplicates | ||
<nowiki> | |||
var returnRequest = #1#; | var returnRequest = #1#; | ||
var allActors = JSON.parse(CommonInterface.callWebservice('SC - Get Service Managers', {})); | var allActors = JSON.parse(CommonInterface.callWebservice('SC - Get Service Managers', {})); | ||
Line 24: | Line 24: | ||
}) | }) | ||
return filteredArray.join('||');<nowiki | return filteredArray.join('||'); </nowiki> |
Latest revision as of 20:10, 4 May 2021
Example how to build an array of persons and in the end filter out the duplicates
var returnRequest = #1#; var allActors = JSON.parse(CommonInterface.callWebservice('SC - Get Service Managers', {})); var allReturnActors = []; var nofActors = 0; for (var i=0;i<allActors.length;i++){ if (allActors[i].OWNEREMAIL && returnRequest.indexOf("1") !== -1) { allReturnActors[nofActors++] = allActors[i].OWNEREMAIL; } if (allActors[i].DEPUTYEMAIL && returnRequest.indexOf("2") !== -1) { allReturnActors[nofActors++] = allActors[i].DEPUTYEMAIL; } if (allActors[i].MANAGEREMAIL && returnRequest.indexOf("3") !== -1) { allReturnActors[nofActors++] = allActors[i].MANAGEREMAIL; } } const filteredArray = allReturnActors.filter(function(ele , pos){ return allReturnActors.indexOf(ele) == pos; }) return filteredArray.join('||');