- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 04:06 AM
Hello Everyone,
I have added a new section(tab) in Incident form. This section has a ui macro which loads more information by making REST api calls on load event(ui macro onload javascript).
The sections are loaded as soon as the incident form is loaded.
My requirement is, I want to call these APIs only when user clicks on this section.
So is there any script which I can run when the tab becomes active?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 06:05 AM
Pleasure!
We had similar requirement long back and convinced customer to go with simpler alternative 🙂
You can mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 04:50 AM
Hello Aditya,
As DOM manipulation is discouraged in client side, we have a couple of options to achieve this in a optimal way.
1) You can create a checkbox of some kind inside that tab(section), onChange define a client script which will call a script include and trigger REST message.
2) You can explore the tab2section methods. You can have a look and determine if any one of these methods can come handy in your case.
https://www.servicenow.com/community/developer-blog/demystifying-form-tabs/ba-p/2287086
You can mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 04:58 AM
Thanks for the response @mdash
If we have a checkbox, how can we make sure it is checked on click of the tab ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 05:14 AM
I am afraid that has to be user initiated. OOTB onChange Client script does not support form section changes.
You can also explore the option of adding an UI action (for ex: Refresh data) instead of checkbox to trigger the REST Call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 05:59 AM
Right, In that case may be I will have a button so that user can initiate.
Thanks for the all information. @mdash