g_scratchpad is showing undefined value in different table

PavanAkola
Tera Contributor

In my case I'm using two different tables . does g_scratchpad work for two different tables ?

 

case:

In incident table there is a field that reference problem table i.e. of name "problem_id" by using display BR and scratchpad i need to move that specific incident number to the respective problem table and set that to a newly created field named "u_incident_ref". 

In system logs it was logging data perfectly but while trying to fetch from problem table client script it was showing as undefined

please refer below screenshots for better understanding!

1 ACCEPTED SOLUTION

smukherjee
Mega Sage

Any Business Rule is defined per table, and I am not 100% sure but g_scratchpad data is likely not shared between tables.

Also, a typical g_scratchpad use case is to pass data between server and client side of the same table, and not between tables.

 

You will likely need to:

1. Write a business rule (probably async) for the Incident table, that does a GlideRecord query of the problem with problem_id as the sys_id,

2. Update the u_incident_ref of the Problem record that came up as result of the query, with the sys_id of the current incident.

View solution in original post

6 REPLIES 6

Murthy Ch
Giga Sage

@PavanAkola 

I beleive it will not work like that because the display BR will run when the incident form loads not when the problem form because the BR is in incident table not in the problem table.

Hope you understood

Thanks,
Murthy

ok but how can i actually solve this case ? is there any other alternative to do this.

 

Gangadhar Ravi
Giga Sage
Giga Sage

@PavanAkola Please refer this.

 

https://www.servicenow.com/community/developer-articles/display-business-rule-and-g-scratchpad/ta-p/...

 

Please mark my answer correct and helpful if this works for you.

smukherjee
Mega Sage

Any Business Rule is defined per table, and I am not 100% sure but g_scratchpad data is likely not shared between tables.

Also, a typical g_scratchpad use case is to pass data between server and client side of the same table, and not between tables.

 

You will likely need to:

1. Write a business rule (probably async) for the Incident table, that does a GlideRecord query of the problem with problem_id as the sys_id,

2. Update the u_incident_ref of the Problem record that came up as result of the query, with the sys_id of the current incident.