Delay Catalog Client Script "OnSubmit"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 10:52 AM
Can we delay onsubmit catalog client script ?
I am facing this issue as script include (Which gets triggered on onchange) is taking time to complete and there is big possibility that users submit the request before script include is executed, causing Catalog task to be created without assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 11:02 AM
Your focus area should be why the script include is taking too long and not the onSubmit client script. Please describe more detail on what this script include does and how your client script is calling it. You may be better off using a client script that calls a scripted rest instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 11:49 AM
Hi Rajnees,
If your function is only on native UI (Not running on service portal ), then you can use getXMLWait() function in your client script. This function will not support in service portal. If you are using on portal then provide some more detail about the functionality.
Refer this link for detail information https://developer.servicenow.com/dev.do#!/reference/api/london/client/r_GLAX-getXMLWait
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Vijay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 12:40 PM
Unfortunately, It is majorly used in Service Portal. I am going to try the option provided by Mike (Using Scripted Rest API)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 01:14 PM
GlideAjax while a nice feature isn't the fastest response. Using an HTTP call in a client script to a scripted rest will be your best option. There are more and more examples of this out of the box with each release. For example here is one included in HR that populates a record producer form:
function onLoad() {
$.get( "/api/sn_hr_core/hr_rest_api/profile?sysId=" + g_user.userID,
function( answer ) {
if (answer) {
var result = answer.result;
for(var field in result)
g_form.setValue(field, result[field].value +"", result[field].displayValue+"");
}
});
}
You just need to adjust to call your scripted rest instead.
Please mark this post or any as helpful or the correct answer to your question if applicable so others viewing may benefit.