Client Script not triggered when using "Close Task" UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I’m facing an issue with a Catalog Task setup.
I created a Catalog Client Script (onLoad) that defines when a specific variable should be displayed based on certain conditions.
In addition, I created a Client Script (onChange) that should make this variable mandatory when those same conditions are met and the task is being closed (state changes to Closed Complete).
However, this logic only works when I manually change the state field, and does not trigger when clicking the "Close Task" UI Action button. In that case, the task is closed first, and only afterward does the variable become mandatory.
Has anyone encountered this behavior before or found a good approach to make the variable mandatory when closing via a UI Action?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You will have to use g_form.getActionName() in your client script:
https://www.servicenow.com/community/developer-forum/getactionname/m-p/1815888
OR
you can also write your client login in UI action:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Why? It answers the same condition of newValue == 3 (closed complete)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
@linoyv691904179 Because the client script executes before the UI action.
So every time we want to run some client action (mostly validations/mandatory) we write that as the client action of UI action.
You can find this in multiple UI actions OOB example , reopen incident.
Please mark the answer correct/helpful accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
But this is an onChange script, g_form.getActionName() won't work, and I don't want to add logic to the ui action since it is only a variable
