Why is g_scratchpad used in onSubmit Catalogue Client Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
I've just been looking at the onSubmit below Catalogue client Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Basically, g_scratchpad will be declared in display business rules to pass the information from Server side to client side. It will not be declared in the client script. You can look at the business rules of the table where the form is being viewed.
-Dhanraj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
in this case it's basically used to handle synchronous GlideAjax
Reason being Synchronous GlideAjax is not allowed in portal and in scoped app
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
@matthew_hughes , g_scratchpad isn't any catalog variable or a script variable to be declared in client scripts.
It's basically used to fetch the data from Server side especially from Display Business Rules.
I am sure in your script - g_scratchpad.isFormValid is already declared in your business rules to fetch some value and then pass it into your Onsubmit Client script.
To learn more about scratchpad , you may go through these docs, articles to get a better understanding -
https://www.servicenow.com/community/developer-forum/what-is-scratchpad/m-p/2118432
https://www.servicenow.com/community/developer-forum/explain-scratchpad/m-p/2256541
If my response has helped you, kindly mark it as helpful and accept the solution.
Regards,
Nayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @matthew_hughes ,
Generally g_scratchpad is used to pass data from server side to client side using Display BR . Im not getting why you are using g_scratchpad as well as glideajax both at time .GlideAjax is also used to fetch server side data to client side using Script include . g_scratchpad is a built-in object provided by ServiceNow, so you don’t need to declare it in the catalog client script. As per my understanding ,it is automatically available on the client side and is commonly used to temporarily store values while a form is open but you need to declare it in display BR means you just need to initialized it in BR. Then you can call that g_scratchpad property in client script .
Im not sure but here based on you glideajax g_scratchpad property value is getting set . is it working ?
