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

Business rule to check the updated by is member of assignment group

Twinkle S
Mega Sage
Mega Sage

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

11 REPLIES 11

make it more simple. 

 

 

try with below sample code. 

 

 

	if(gs.getUser().getUserByID(current.sys_updated_by).isMemberOf(current.assignment_group)){

		gs.log('inside if');
current.u_responed=true;
	}

	else {
		
		gs.log('hey else');
	}

 

Note: Make sure you have written before business rule on UPDATE and you don't need to use current.update().

HEllo Twinkle,

sys_updated_by is not reference field. its taking th user_name . so you need to gliderecord the user table and fetch the sysid or you can check it their itself.


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

Thank you,
Abhishek Gardade