- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 07:06 AM
Hi All,
I have a Client Script- OnChange which should prevent the users when they try to select the Approved status on the Change task form from the Status field. The script is working fine and showing an error message as expected when they select the Approved value from the Status field. But the problem I am facing is when the task is approved by the user from the Approvers tab that time also I am seeing the same error message as the script is written on OnChange.
Is there a way to prevent the Client Script firing when the task is approved from the Approvers tab?
Any help is really appreciated!!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 12:48 PM
Hi Siva,
This issue occurs when we approve an item from approver's related list and status of the item changes to "Approved" without form refresh. This is called live updating and we need to make sure that your script does not run when there is a live update on the field you have written your onChange client script on.
You need to add an if condition in your client script something like below and it should work.
if(!g_form.isLiveUpdating()){
////your code
}
Please mark my answer correct if it works.
Regards,
Rajnish Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 08:24 AM
Hi Siva,
Maybe you could check for specific roles in the client script and do/don't show the message based on that.
You can check roles of the logged user with:
g_user.hasRole('name of role');
It will be true of the user has the role or false if the user hasn't it.
Hope it helps!
Joaquín
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2020 02:35 AM
Hi Joaquin,
Thanks for your response. But checking the logged-in user's role will not work as the same person will try to change the status to "Approved" and after seeing the error message user will approve from the Approvers tab.
I am looking for a way to identify when the task is approved from the Approvers tab. I can use that in the client script to stop the client script.
Thanks
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2020 03:34 AM
Hi Siva,
onChange client script works only on form and not from the list?
Can you share screenshot where the error is shown and how you are testing?
Also the script written?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 06:14 AM