Can "starts with" be a condition within a Client Script?

Edwin Fuller
Tera Guru

I need to write an onLoad Client script that checks if the parent field starts with a 3 letter prefix of "CUS". I have not has much success with this can someone show me how this would be written?

Thanks,

Edwin

1 ACCEPTED SOLUTION

Okay... sounds like a UI Policy to flick the visibility of the related list may do the trick... provided you can dot-walk to the parent field.



I may have a play with this to see if the parent field is accessible.


View solution in original post

7 REPLIES 7

Deepak Kumar5
Kilo Sage

Startwith does not work in client script.


You have to get the value using getValue and then check the string start with "CUS" using match function (Javascript)


Hi Edwin,



You can try like this:-



var a=g_form.getValue('field name');


if(a.startsWith('CUS'))


{


you code.......
}


else



{



}


Dave Smith1
ServiceNow Employee
ServiceNow Employee

I need to write an onLoad Client script


Does it need to be a Client Script?  



What's the end objective?   If it meets this criteria... what then?


If the parent field starts with 'CUS' then I need to show a certain related list, otherwise I need to hide that related list.