Assignment group is not populating in Incident table

Dileep2
Tera Contributor

Hi All,

 

I have created Inbound email action and with the help of attached script by sending email, I can create new records in the Incident table with all the values except assignment group.

Please suggest

var emailSubject = email.subject; // Get the subject line of the email
var callerEmail = emailSubject.match(/[a-zA-Z0-9._%+-?#]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/)[0]; // Extract email using regex
// Look up user based on the email address
var user = new GlideRecord('sys_user');
user.addQuery('email', callerEmail); // Query for user with the extracted email
user.query();

var incidentSysID; // Declare the incident Sys ID variable

if (user.next()) {
    // User found, proceed to set the caller and affected user
    current.caller_id = user.sys_id;
    current.u_affected_user = user.sys_id;
    current.priority = 3;
    current.short_description = email.subject;
    current.description = email.body_text;
    current.location = gs.getUser().getLocation();
    current.u_phone = gs.getUser().getRecord().getValue('phone');
	//current.assignment_group = 'd3059792131fd240adce3b27d144b07d';
	//current.assignment_group = "KRONOS - US";
	//current.assignment_group.sys_id='d3059792131fd240adce3b27d144b07d';
	current.assignment_group.name = "KRONOS - US";
	//current.assignment_group.setDisplayValue('KRONOS - US');
    current.insert();
} else {
    gs.info('User with email ' + callerEmail + ' not found.');
}

 

1 ACCEPTED SOLUTION

B_Engelstock
Tera Expert

Use this syntax (do not use sys_id in the field name):

current.assignment_group='d3059792131fd240adce3b27d144b07d';

View solution in original post

12 REPLIES 12

Hi Ankur,

Thanks for your reply

Assignment group is not populated with the above script.

B_Engelstock
Tera Expert

I recommend making an entry for group sys_id in sys_properties, so it can be changed without making changes in the inbound actions script. Assignment Groups changes over time.

Uncle Rob
Kilo Patron

UncleRob_0-1734007752420.png

 

I see you've already attempted to make current.group a sys_id.
I wonder if the system is just barfing on that?  A couple things you should do.
1)  Copy the group's sys_id again to be absolutely triple ultra sure its not a syntax error.

2)  Check the group's type to ensure its has the "itil" value.

Assuming either of those was the culprit, DO take @B_Engelstock 's advice and govern this with a sys_property instead of a raw sys_id in a script.  This video explains HOW AND WHY.

https://youtu.be/1YA8PG348Hs

Hi @Uncle Rob 

 

Thanks for your reply

have tried the above script but it didn't help.

I didn't ask you to try a script.
I asked:
1)  Are you absolutely triple ultra sure you've got the correct sys_id for a record in sys_user_group table?

2)  Have you verified that the group in question has a type of "itil"