- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 07:28 AM
Hi All,
Below is my business rule which is trying to fetch Assignee Group role however it is not working, grRole.getDisplayValue('role') is not fetching any value.
(function executeRule(current, previous /*null when async*/) {
//var temVar = new HelloWorldSN();
//var assinGrp = temVar.func2();
var assigneeGroup = current.getDisplayValue('assignment_group');
gs.log("assigneeGroup" + assigneeGroup);
var grRole = new GlideRecord('sys_group_has_role');
grRole.addQuery('group',assigneeGroup);
grRole.query();
var temRoel = grRole.getDisplayValue('role');
gs.log("temRoel "+ temRoel);
if(grRole.next()){
current.setValue('x_95063_servicenow_assigneegrouprole',"itsm");
current.update();
}
})(current, previous);
Regards
Kapil Shinde
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 07:47 AM
Hello Kapil,
Create a BEFORE business rule with the below modified script. Don't use current.update(); in before business rule to avoid performance issues.
(function executeRule(current, previous /*null when async*/) {
var assigneeGroup = current.getDisplayValue('assignment_group');
gs.log("assigneeGroup" + assigneeGroup);
var grRole = new GlideRecord('sys_group_has_role');
grRole.addQuery('group.name',assigneeGroup);
grRole.query();
if(grRole.next())
{
var temRoel = grRole.getDisplayValue('role');
gs.log("temRoel "+ temRoel);
current.setValue('x_95063_servicenow_assigneegrouprole',"itsm");
}
})(current, previous);
Reference:
http://wiki.servicenow.com/index.php?title=GlideRecord

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 08:33 AM
Can you please ONLY share instance URL and I will take a look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 08:48 AM
Please find below, just to highlight that tomorrow I have a demo with the customer on this instance. Thanks for your help.
https://dev21184.service-now.com/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 09:19 AM
I just tested for one of the record "INC0010166" and I see assignegrouprole was populated. I also updated business rule to BEFORE and removed current.update().
As I mentioned don't use current.update() in before business rule to avoid performance issues.
Let me know if you have any questions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 08:03 AM
Hi Kapil,
Did you try this in a Before Business rule/Onupdate? Also what type of field is x_95063_servicenow_assigneegrouprole?
var assigneeGroup = current.assignment_group;
gs.log("assigneeGroup" + assigneeGroup);
var grRole = new GlideRecord('sys_group_has_role');
grRole.addQuery('group',assigneeGroup);
grRole.query();
var temRoel = grRole.getDisplayValue('role');
gs.log("temRoel "+ temRoel);
if(grRole.next()){
current.setValue('x_95063_servicenow_assigneegrouprole','itsm');
}
})(current, previous);
Please mark this response as correct or helpful if it assisted you with your question.