"g_scratchpad is not defined" when calling ui action (scoped)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 12:52 AM
Hi all,
having a strange log entry that I can't understand & avoid.
I'm using a (scoped) on before display business rule to set a g_scratchpad to true/false to use it for a (scoped) ui action as condition.
All works fine and as it should.
Scratchpad is set as expected and UI action only visible is g_scratchpad is true (by default the g_scratchpad is set to false via the business rule.
Just one thing is strange .. the ui action will perform a serverside change on the record after which the UI action is not to be visible anymore (and it isn't) as the g_scratchpad will be false after using the ui action .. all ok ... just a log will show up saying:
I mean this is no issue .. as all works fine, just I'd like to avoid this messages ..
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 03:10 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 01:55 AM
Hi,
Check this website. Maybe you will find some interesting information.
https://servicenowgems.com/2016/10/10/understanding-scratchpad-g_scratchpad/
Please mark reply as Helpful/Correct, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 02:29 AM
Hello,
g_scratchpad can only be used in business rules that are on display, otherwise it wouldn't be filled.
See those link for details: https://www.oreilly.com/library/view/learning-servicenow/9781785883323/cb4b394d-3406-450d-a6e0-9bdb0... and https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/app-store/good_practices/client_s....
Mark it helpful or correct if it helps you.
Cheers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 03:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 03:26 AM
in this example they get the data from g_scratchpad that was already filled somewhere on the server side. Thats why they used the GlideSystem .nil (gs.ni) in order to verify if it already had been filled in the server side.
NB: This global variable get filled in the server side (Business rules, script includes,...) and consummed in the client side (ui action, client script...).
So, before judging the behavior of a scratchpad variable you should consider if you are in client/server side.