Create a Incident when a user is added to a group through a workflow

Nathan Okh
Mega Sage

I have a requirement to Create an Incident when a user is Added to a Group.

So when Group A has a User added to its membership an incident is created with the following information:

User Added == Caller ID, Affected User

Short Description: {User Added.name} added to Group A
Description:  {User Added.name} to Group A, {User Added.title}

 

I was able to get a notification sent out when this happens. I can create an incident, but I'm having trouble populating the added information user (like their name, title, department etc.) 

NathanOkh_0-1706118710983.png

var Inc= new GlideRecord("incident");
Inc.initialize();
Inc.short_description = "Access Request - GroupA - " + current.variables.user.name; //current.variables.user.name does not work

Inc.assignment_group = '12341234'; //GroupAACCESS
Inc.category = 'software';
Inc.u_affected_software = 'GroupA';
Inc.u_subcategory_software = 'access_GroupA';
Inc.state = '1';

Inc.caller_id = current.variables.user.name;  //current.variables.user.name does not work
Inc.u_affected_user = current.variables.user.name;  //current.variables.user.name does not work

Inc.description = 
"Please provide appropriate access for, " + '\n' +
	"Requested for: " + current.variables.user.name + '\n'+
	"Department: " + '\n'+
	"Title: "+ '\n'+'\n'+
	
Inc.insert();


gs.addInfoMessage(gs.getMessage('record inserted:'+current.number));
1 ACCEPTED SOLUTION

Nathan Okh
Mega Sage
3 REPLIES 3

Elijah Aromola
Mega Sage

Can you share your script?

var Inc= new GlideRecord("incident");
Inc.initialize();
Inc.short_description = "Access Request - GroupA - " + current.variables.user.name; //current.variables.user.name does not work

Inc.assignment_group = '12341234'; //GroupAACCESS
Inc.category = 'software';
Inc.u_affected_software = 'GroupA';
Inc.u_subcategory_software = 'access_GroupA';
Inc.state = '1';

Inc.caller_id = current.variables.user.name;  //current.variables.user.name does not work
Inc.u_affected_user = current.variables.user.name;  //current.variables.user.name does not work

Inc.description = 
"Please provide appropriate access for, " + '\n' +
	"Requested for: " + current.variables.user.name + '\n'+
	"Department: " + '\n'+
	"Title: "+ '\n'+'\n'+
	
Inc.insert();


gs.addInfoMessage(gs.getMessage('record inserted:'+current.number));

Nathan Okh
Mega Sage

The solution can be found here: 

 

Create Incident when a user is added to a group