The CreatorCon Call for Content is officially open! Get started here.

current.assignment_group is not working in Business rules

Mr_Blue
Tera Expert

Hello Guys,

can you please suggest what to do here, in the below code so that things will work fine again .

 

My Code :

 var grProblem = new GlideRecord('problem');
grProblem.initialize();
grProblem.setValue('short_description', 'PRB generated from P1 ' + current.getDisplayValue());
grProblem.insert();
current.assignment_group='Database Atlanta';         // Not working 
current.assigned_to='bow.ruggeri@example.com';   // Not working 
current.setValue('problem_id', grProblem.getUniqueValue());
current.update();

 

Thank you in advance

1 ACCEPTED SOLUTION

AbhishekGardade
Giga Sage

hello Bright,

As assignment_group & assigned_to is reference field, you need to pass a sys_id of assignment_group & assigned_to.

current.assignment_group='SYS ID of Database Atlanta';         // Not working 
current.assigned_to=' SYS ID of bow.ruggeri@example.com';   // Not working 

OR

Try using below code:

current.setDisplayValue('assignment_group','Database Atlanta');
current.setDisplayValue('assigned_to','bow.ruggeri@example.com');

For more details: 

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_GlideRecord-setDisplayValue_String_O...

Few recommendations:

1. I would recommend to use grProblem.getValue('sys_id') in place of grProblem.getUniqueValue();\

2. If you are using BEFORE BR then No Need to of current.update();

3. If you are using AFTER BR then you can add one more line current.setWorkflow(false); before current.update(); OR Not to use current.update(); 

https://docs.servicenow.com/bundle/madrid-application-development/page/script/business-rules/referen...

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

View solution in original post

6 REPLIES 6

Vinay Mishra3
Mega Guru

Hi Bright,

Please try below code

 

current.assignment_group.setDisplayValue('Database Atlanta');
current.assigned_to.setDisplayValue('bow.ruggeri@example.com');

 

Please make helpful/correct, If its applicable for you.

Thanks,

Vinay

Hey Thanks Alot, #Vinay Mishra