javascript string matching error

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
I am trying to compare two strings.ALthough both the values are same still the block is not executing
here is the code
var applicationModel = skuid.model.getModel('Application');
//alert("applicationModel "+applicationModel);
var applicationRow = applicationModel.data[0];
//alert("applicationRow "+applicationRow);
var appId =applicationRow.Id;
//alert("applicationRow.Id "+ applicationRow.Id);
var stat=applicationRow.genesis__Status__c;
//alert("stat " +stat);
var ad=applicationRow.genesis__Auto_Decisioning__c;
alert("autodecisioning " +ad);
var newstat="NEW - PRICING GENERATED";
//alert("newstat " +newstat);
var admatch="true";
alert("admatch " +admatch);
var newstat2="APPROVED - CONVERTED TO CONTRACT";
var agree = confirm("Are you sure ?");

if (agree){

if (stat.toUpperCase() == newstat2)
{
alert("Application is alerady Converted ");
}

else if (stat.toUpperCase() == newstat)
{

var str = ad.valueOf();
alert('sholud be true : '+ str);
//if(str == 'true')
//alert('str'+str);
//alert('admatch.valueOf()'+admatch.valueOf());

if(ad.valueOf() == admatch)
{

alert("status matched");
var retVal = sforce.apex.execute("DemooOrgUtils","borrowerAccepted",{app:appId});
//alert('retVal'+retVal);
window.location.reload();
}
else{
alert("Please enable Auto Decisioning ");
}
}
else
alert("Please generate pricing AND enable Auto Decisioning ");
}

this (ad.valueOf() == admatch) part is not executing although both contains 'true'.Any idea?
Photo of Raya Banerjee

Raya Banerjee

  • 456 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Does ad.valueOf() actually give you results?  
Is it a similar data type as admatch (which just looks to be a text string rather than a boolean)
Photo of Raya Banerjee

Raya Banerjee

  • 456 Points 250 badge 2x thumb
yup.ad.valueof()  showing  'true' as it shows in the variable 'str'.
I need to check weather ad is true or false.Is there any other way to do that ?
(Edited)
Photo of Raya Banerjee

Raya Banerjee

  • 456 Points 250 badge 2x thumb
The code works beautifully ,Thank you.I got the solution . It should ad===true.