Business rule to check the updated by is member of assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:34 AM
I have a requirement to make a custom field Respond set to true if the updated by is the member of current assignment group.Everything works fine except the if condition, if condition is not fulfilling. Below is the code for After update
(function executeRule(current, previous /*null when async*/) {
var a=current.sys_updated_by;
var b=current.assignment_group;
var c=gs.getUser();
gs.addInfoMessage(b);
gs.addInfoMessage(a);
if(current.sys_updated_by.isMemberOf(current.assignment_group))
{
gs.addInfoMessage('inside if loop');
current.u_responed=true;
}
Regards
Twinkle
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:42 AM
Hello all,
I dont want to check the getUser . I need to check updated by. Also, the setworkflow() will only work only if the codition is matched. The if condition itself is not fulfilling
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:45 AM
Try this code now:
var a=current.sys_updated_by;
var b=current.assignment_group;
var c=gs.getUserID();
gs.addInfoMessage(b);
gs.addInfoMessage(a);
if(a.isMemberOf(current.assignment_group))
{
gs.addInfoMessage('inside if loop');
current.u_responed=true;
current.setWorkflow(false);
current.udpate();
}
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:43 AM
try now.
(function executeRule(current, previous /*null when async*/) {
var a=current.sys_updated_by; // this field return the user_id so you have to glide record here to get the sysid.
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name',a);
gr.query();
if(gr.next()){
var res = gr.sys_id;
var b=current.assignment_group;
var c=gs.getUserID();
gs.addInfoMessage(b);
gs.addInfoMessage(a);
if(res.isMemberOf(current.assignment_group))
{
gs.addInfoMessage('inside if loop');
current.u_responed=true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:49 AM
Nope. Not happening.Its not going inside the if loop

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:53 AM
can you put some log and validate it.
var a=current.sys_updated_by;
gs.log('Updated By is'+ a);
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name',a);
gr.query();
gs.log('Row Count+ gr.getRowCount());
if(gr.next()){
var res = gr.sys_id;
var b=current.assignment_group;
var c=gs.getUserID();
gs.addInfoMessage(b);
gs.addInfoMessage(a);
if(res.isMemberOf(current.assignment_group))
{
gs.log('Comimng inside if block ');
gs.addInfoMessage('inside if loop');
current.u_responed=true;
}
}