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:37 AM
Hello Twinkl,
Check out the below code: You missed current.update().
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();
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:38 AM
Hi,
In If condition you need to use c.isMemberOf() instead of a.isMemberOf().
var a=current.sys_updated_by;
var b=current.assignment_group;
var c=gs.getUser();
gs.addInfoMessage(b);
gs.addInfoMessage(a);
if(c.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:40 AM
Also, switch BR to before update as using setWorkflow(false) may have negative impacts as per my previous experience

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 02:40 AM
try if(gs.getUser().isMemberOf(current.assignment_group))
Thank you,
Ali