How can i script Contains("string") or matching

alpha2nl
Kilo Explorer

Below script don't works, what is de function contains in SN

 

if(this.rec.u_service.containg("SAM") && this.rec.u_subtype == ""){

      allowed = true;

      }

Maby something like indexOf

Thanks!

6 REPLIES 6

josh_nerius
ServiceNow Employee
ServiceNow Employee

Excellent, thanks for the update! Please remember to mark the thread as resolved.


Hello Dalab,



I am having similar issue you had earlier. I have Reference Type catalog variable. The backgroundColor of the variable should be styled to Green color if the name contains "green" .



for example: #Client Script



var myVar = $('sys_display.'+ g_form.getControl('<variable_name>').id);



  if(the variable contains(green))


{


      myVar.style.backgroundColor = 'green';


          }


Could you please help me writing the condition?


Thank You