g_scratchpad is not working giving error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 04:25 AM
onSubmit script error: ReferenceError: g_scratchpad is not defined:
function () { [native code] }
code1:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 04:50 AM
Hello @gautam_dhamija ,
Your approach is not good, as the g_scratchpad is only used with the display business rule. If you are using the GlideAjax then you don't need to use g_scratchpad. Use out of one at a single time.
Please mark my answer as accepted solution and give thumbs up, if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 04:59 AM
but i need to prevent the form submission if the response from the script include is false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 06:28 AM
Hello @gautam_dhamija ,
Then instead of using the script include, use the Display BR with scratchpad and then call that scratchpad from client script.
Please mark my answer as accepted solution, if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 05:13 AM
Hello @gautam_dhamija
The g_scratchpad is commonly used to pass data from a Display Business Rule to a Client Script by assigning values on the server side and accessing them on the client side. However, since you're using GlideAjax to fetch data from the server and perform operations, g_scratchpad may not be the best choice in this case.
Additionally, if you're encountering a "g_scratchpad is not defined" error, it is likely because no data has been passed from the Display Business Rule to the g_scratchpad variable. This typically happens when there’s no logic in the Display Business Rule to assign values to g_scratchpad.
Instead of relying on g_scratchpad, you can achieve the same functionality by writing a Script Include. The Script Include can contain the server-side logic, and you can then use GlideAjax in your Client Script to call the Script Include and retrieve the required data.
This approach is more dynamic and efficient, especially if you're working with asynchronous operations or need to fetch fresh data from the server.
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar