Need to populate group members in worknotes

Feroz1
Tera Contributor

Hi Team,

Based on the assignment group selection on the incident in need to populate all the group members in worknotes.please help me with the approach and script.Thanks in advance.

3 REPLIES 3

James Chun
Kilo Patron

Hi @Feroz1,

 

You can write a Before Business Rule on insert/update. Below is an example script:

 

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

	var memberArr = [];
	var grpMemberGr = new GlideRecord('sys_user_grmember');
	grpMemberGr.addEncodedQuery('group=' + current.getValue('assignment_group'));
	grpMemberGr.query();
	while(grpMemberGr.next)
	{
		memberArr.push(grpMemberGr.user.name.toString());
	}
	if(memberArr.length != 0)
	{
		current.work_notes = "Members of the group are " + memberArr.join(',');
	}

})(current, previous);

 

Hope it helps, thanks

Hi James I have written the br. But the script is not working.

Hi ! 

 

The script shared above must work ! But you have to make sure you have configure your BR properly. Check the when to run condition and try to add logs in script to see we're it's stopping .

 

When do you want this worknotes to be updated ? What's your condition...

 

Share screenshot of possible...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect