nunnapradeep868228

Match and Duplicate check in Map using Javascript

Discussion created by nunnapradeep868228 on May 4, 2017

Hi,

 

I just came across one of the requirement. I have multiple fields in source profile. I have to check which field is matching input parameter. Also, I need to notify if Input parameter is matching more than one field. I have used this below code using Java script array functions.

 

var SessionObjID = "";
var isDuplicate = "false";

var inputArray = ["123", null, "", "", "", "", ""];

var newArray = inputArray.filter( function(value, index, self){return self.indexOf(value) === index && value !== undefined && value !== null && value !== ""; });

var matchCount = newArray.length;
if(matchCount > 1){
isDuplicate = "true"
}if(matchCount == 1){
SessionObjID = newArray[0];
}

 

Regards,

Pradeep

Outcomes