Monday, October 10, 2016

Compare Two Lists

var jurisdictionMap = {};

tw.local.errorMessage = "";

for (var i = 0; i < tw.local.jurisdictionNVP.listLength; i++) {
    jurisdictionMap[tw.local.jurisdictionNVP[i].name] = tw.local.jurisdictionNVP[i].value;
}

for(var i=0;i< tw.local.clientCashRows.listLength; i++)
{
    var jurisdictionName = tw.local.clientCashRows[i].jurisdiction;
    if(!!jurisdictionName)
    {
         if(!jurisdictionMap[jurisdictionName])
         {
              tw.local.errorMessage += (tw.local.errorMessage ? ", " : "") + jurisdictionName;
              var errorMessage = "Jurisdiction is not present in table Please verify once " + jurisdictionName;
              log4j.error(errorMessage);
         }
    }
}

if (tw.local.errorMessage) {
    tw.local.errorMessage = "The following Jurisdiction are not present in the Jurisdiction Table: " + tw.local.errorMessage;
    tw.local.isError = true;
 }

No comments:

Post a Comment