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

Zod
Giga Guru

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:

find_real_file.png

I mean this is no issue .. as all works fine, just I'd like to avoid this messages .. 

Thank you!

9 REPLIES 9

Bozhidar Dimitr
Giga Expert

Hey,

Could you please provide your UI Action code? Seems like you're trying to access the g_scratchpad from the server function from the action, hence the g_scratchpad is undefined (you also CANNOT use the g_scratchpad in the condition as conditions are server-side as well).

Also, quick remark, the g_scratchpad should be treated as an object, not as a variable. You should never set the g_scratchpad to anything, instead declare new key-value pairs like so:

g_scratchpad.shouldShow = true;
g_scratchpad.someText = 'someTextValue';

and then you can use the values by calling g_scratchpad.<keyName> from your client scripts.

The reason to treat is an object is that there might be several onDisplay business rules populating the g_scratchpad. You would not want to override it and risk breaking old functionality or limiting new.

Cheers!

Thanks. I just do not get it really.

Within the business rule i set g_scratchpad.check to true/false ... in the condition of ui action I check for g_scratchpad.check .. did that may times already and never had any issues.

And it works as I said. Just the log message comes up ... 

 

find_real_file.png

 

Hey,

As mentioned - the g_scratchpad is only readable by onDisplay BRs and client scripts.

The condition of the UI Action is server-side script so you cannot really use the g_scratchpad there. What are you trying to achieve? A different approach will be needed for this 🙂

??? For the condition saying in which cases the ui action should be visible or not, usually the g_scratchpad is to be used ... at least I sure I got this out of some best practice posts ... and it IS WORKING FINE ... . 

The condition field usually is to short to get all the things checked, so a scratchpad is required or a script include. But due to performance reasons the scratchpad is to be chosen ... 

Think you are wrong here. It is absolutely working with the scratchpads ...  Reliably .. just the log entry ;-/