- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 02:25 AM
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.');
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 06:01 AM
Use this syntax (do not use sys_id in the field name):
current.assignment_group='d3059792131fd240adce3b27d144b07d';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 05:01 AM
Hi Ankur,
Thanks for your reply
Assignment group is not populated with the above script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 03:37 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 04:51 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 05:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 05:06 AM
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"