send value from business rule to client script

FIKRI BENBRAHIM
Kilo Guru

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

1 ACCEPTED SOLUTION

FIKRI BENBRAHIM
Kilo Guru

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

View solution in original post

8 REPLIES 8

When i check the log, i find an empty value in g_scratchpad.Assignement_Groupe.getDisplayValue().

FIKRI BENBRAHIM
Kilo Guru
Thanks for your reply Shashikant Yadav. But i have already seen this  question in the community and it's not helping. 
I guess getDisplayValue() whould have healped if i had the sys_id

Yes, because assignment group is reference field.

What value you are getting in current.assignment_group? Can you pass the static value under scratchpad and check the log

g_scratchpad.Assignement_Groupe = 'Test Value';

FIKRI BENBRAHIM
Kilo Guru

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