
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2018 08:26 AM
He lo every one,
I want to send a sys_id of a reference field from a Business rule to a Client Script. For that i use the global variable SCRATCHPAD in business rule to fill in the value from the database into scratchpads property, then i user the same scratchpad value in a client script to read the value from the scratchpad.
But i can't manage to fill in the value of the reference field named "assignment_group" in the Business rule because the logs show an empty reference fields value. Here is my Business rules onDisplay code:
g_scratchpad.Assignement_Groupe_SysId = current.assignment_group;
gs.log('g_scratchpad.Assignement_Groupe_SysId = '+g_scratchpad.Assignement_Groupe_SysId+'!!!!!!!!!!!!');
Can someone help me solve this problem please? Because i am a beginner in servicenow
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2018 08:43 AM
Hello all,
Actually the business rule has to be on Display in order for the scratchpad variable to work.
See this link related to scratchpad global variables with business rule: Link.
See the link related to using the scratchpad variables of a workflow: Link.
Kind regards
FIKRI BENBRAHIM Mohamed Jawad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2018 08:33 AM
The record which you opened has the assignment_group value? Please share your client script code as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2018 09:15 AM
Yes it already has the assignment_group value. Here are my business rule script and my client side script:
////Business rule onDisplay
(function executeRule(current, previous /*null when async*/) {
// Get the sys_id of the Assignement Groupe NY DB for the Client Script SetHealthType
g_scratchpad.Assignement_Groupe_SysId = current.assignment_group;
gs.log('g_scratchpad.Assignement_Groupe_SysId = '+g_scratchpad.Assignement_Groupe_SysId+'!!!!!!!!!!!!');
})(current, previous);
////Client Script on Change
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// Get the Assignement groupes sys_id scratchpad value from the Business Rule getAssignementSysId
var AsigGrp = g_scratchpad.Assignement_Groupe_SysId;
alert('Alert gets executed !!!!');
g_form.setValue('u_my_field_label', g_scratchpad.Assignement_Groupe_SysId);
alert('The Assignement Groupes sys_id : '+g_scratchpad.Assignement_Groupe_SysId);
//}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2018 08:35 AM
Hi,
You can write below Script:
Business Rule:
g_scratchpad.Assignement_Groupe_SysId = current.assignment_group;
OnLoad Client script:
alert(g_scratchpad.Assignement_Groupe_SysId);
Below link will help you:
https://community.servicenow.com/community?id=community_question&sys_id=9fa5cfeddbd8dbc01dcaf3231f961906
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2018 08:39 AM
Can you check the log as given below:
gs.log('g_scratchpad.Assignement_Groupe_SysId = ', g_scratchpad.Assignement_Groupe_SysId.getDisplayValue());
Thanks
Shashikant