
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 09:41 AM
I have the following requirement for the incident form: If the state changes to on hold, or the priority is escalated (changes to numeric value less than previous value), comments should be mandatory.
Sounds simple, but no luck in practice. My thought was to run two different client scripts, one on change of state and the other on change of priority. The problem is, in my client script on change of state I have no way to check if the priority was escalated or not. If the state changes from on hold back to something else I would want to make comments not mandatory, only if there is not a priority escalation.
Is there a way I could pass a flag from one client script to the other?
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 09:50 AM
You can achieve these requirements using business rule.
You can check if priority or state is changed, and then implement your validation in business rule.
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 11:10 AM
Hi Chris,
You cannot pass any data between client scripts. However, you can use a hidden field in the form and can achieve this.
On change of priority as per your requirement, you set the value of priority in the hidden field. On the change of state, you can access the hidden field value and can check in combination with state value and make the comments field mandatory using g_form.setMandatory()
Hope this helps.
Mark the answer as correct and helpful if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 08:53 PM
Hi,
Did you try the solution given above?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2019 09:45 AM
I ended up going with the solution of using a business rule instead of a client script for the validation. But thank you for the suggestion as that would likely work as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2020 02:31 PM
Hi Asifnoor,
I had a similar requirement and I tried using the hidden field in the client script as you have suggested and I wrote an OnLoad script to hide the field on form load since unchecking the visibility options in the variable did not store the value in the hidden field so when I tried to hide it (g_form.setVisible('hiddenfield',false)) in On Load script it worked for me.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 11:22 AM
Why not use a display Business rule and store the value in g_scratchpad variable and pass that information on to Client Script.
https://servicenowgems.com/2016/10/10/understanding-scratchpad-g_scratchpad/
Please mark my response as correct and helpful if it helped solved your question.
-Thanks