Client Script Control

user_ms
Tera Expert

If there are two Client Scripts below:

- Client Script 1

  Set a value to clumn_a

 

- Client Script 2

  Field Name :clumn_a

  onChange

  Set a value to clumn_b

 

I want to stop Client Script 2 from running when the value of clumn_a is changed in Client Script 1.

Is there any way to do this?

1 ACCEPTED SOLUTION

jMarshal
Mega Sage
Mega Sage

On first evaluation/thought, have a hidden intermediate boolean variable (clumn_a_changed) which is set to "true" if the value is set to "clumn_a" in client script 1 and start the second client script with an "if (clumn_a_changed == false) { script_stuff; } else { return; }" type of statement

 

what are you triggering your client script(s) on? if they trigger on the same thing, I think you'll need to set an order (I believe this is possible)

View solution in original post

4 REPLIES 4

jMarshal
Mega Sage
Mega Sage

On first evaluation/thought, have a hidden intermediate boolean variable (clumn_a_changed) which is set to "true" if the value is set to "clumn_a" in client script 1 and start the second client script with an "if (clumn_a_changed == false) { script_stuff; } else { return; }" type of statement

 

what are you triggering your client script(s) on? if they trigger on the same thing, I think you'll need to set an order (I believe this is possible)

user_ms
Tera Expert

@jMarshal 

Thank you for your answer.

The trigger for Client Script 1 is clumn_c, and the trigger for Client Script 2 is clumn_a, which was set in Client Script 1.

I will try to use intermediate boolean variable.

 

glad I could help. just be sure to add the field to your form as a hidden field, you cannot just create the custom field on the table and have it accessible to a client script, it needs to be on the form to be set and referenced.

Ankur Bawiskar
Tera Patron
Tera Patron

@user_ms 

why not merge both the client scripts and set value in column b?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader