How to check certain string in a variable is contained in another table's field

SNowUser11
Kilo Guru

Hi Experts,

I have queried value of a field (in my case from Location field) and stored in a variable like var rec = current.location.name.toString();

Now I want to compare that string which I got in rec if that is CONTAINED in other table's field (field name is Area because they are not exact matching but the string in Area contains the characters which I got in rec. 

Will indexOf(rec)>-1 work i mean putting the variable name instead of actual string in it or how does it please guide.

Thanks

1 ACCEPTED SOLUTION

Shantharao
Kilo Sage

Hi,

 

function ifScript() {

 

var Area = current.variables.requested_for.location.getDisplayValue();
if (Area .toString().indexOf('UKBAS1') >= 0) {

// instead of "UKBAS1" string part you can specify your string which is common in both the fields 
  return 'yes';
 
}
return 'no';
}

 

if my response helps you please hit and mark as correct answer

View solution in original post

3 REPLIES 3

Jaspal Singh
Mega Patron
Mega Patron

Yes, putting it in form

yourAreafield.indexOf(rec)>-1 should work as -1 is a search for Contains 

Shantharao
Kilo Sage

Hi,

 

function ifScript() {

 

var Area = current.variables.requested_for.location.getDisplayValue();
if (Area .toString().indexOf('UKBAS1') >= 0) {

// instead of "UKBAS1" string part you can specify your string which is common in both the fields 
  return 'yes';
 
}
return 'no';
}

 

if my response helps you please hit and mark as correct answer

HI

Good solution. Why not directly put the "rec" variable, where you have the "'UKBAS1" string...

Then, you've got it.

BR

Dirk