Notification to users in a list collector

Cirrus
Kilo Sage

Hi,

Can anyone advise if there is a way to do this please. 

We have a list field on a form, and we want to send a notification to the users in the list when someone new is added. However, we only want to send the notification to the original users in the list, and exclude the new user.

I have created a Before Update BR below which triggers the notification, but it sends it to the new user as well.

Is there a way we can exclude the new user from receiving the notification?

 

(function executeRule(current, previous /*null when async*/ ) {

    var getListusers = current.collaborators.toString();
    var splitusers = getListusers.split(',');
    for(var i=0;i<splitusers.length;i++){
        gs.eventQueue('collaborators.updated',current,splitusers[i]);
    }

})(current, previous);
1 ACCEPTED SOLUTION

Hi @Cirrus , try this - 

var pre = previous.watch_list;
	var cur = current.watch_list;
	var preArr = pre.split(',');
	var currArr = cur.split(',');
	var difference = new global.ArrayUtil().diff(currArr , preArr);
	gs.eventQueue('test.notify',current,difference.toString());

This way, even if someone is removed from the list, a notification will not be sent.

View solution in original post

9 REPLIES 9

Hi @Cirrus , try this - 

var pre = previous.watch_list;
	var cur = current.watch_list;
	var preArr = pre.split(',');
	var currArr = cur.split(',');
	var difference = new global.ArrayUtil().diff(currArr , preArr);
	gs.eventQueue('test.notify',current,difference.toString());

This way, even if someone is removed from the list, a notification will not be sent.

Nishant8
Giga Sage

Hello @Cirrus , You can make use of previous instead of current to send notification to older list.  for e.g.

var getListusers = previous.collaborators.toString();

 

Regards,

Nishant

Thanks Nishant. Previous works. Is there a way to reverse this to only get the new user from the list?

 

You can put new (current) and previous in 2 arrays and find the difference.

ArrayUtil - Global

-Anurag

Hello @Cirrus, Glad to hear that previous solved the older list issue. for the new user, you will have to compare previous and current and then take out the remainder. If you find it difficult to do, please let me know, I'll help you with the script part of the same

 

Regards,

Nishant