- 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 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 06:34 AM - edited ‎12-12-2024 06:40 AM
Try and check what happens on the form when you create the incident. Open the Inc and click "show XML" in the burger menu (1) and locate the assignment_group field (2). Here you should see the sys_id and the display name of the group. If the display name is missing, the sys_id is saved in the field but nothing is shown. This would mean it is an invalid sys_id.
If both sys_id and name is not shown, sys_id is not saved to the field.
It looks like that in the OOB version, you can select a group that is inactive and does not have the type field defined as "itil". Does not make sense, but that is the way it is, so you should be able to use a sys_id of a group without focusing on if group is active and has type "itil". The reference qualifier condition should be modified.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2024 08:46 AM
Hi @Dileep2 ,
My understanding is problem is not with the script, I can see you have tried all possible ways of populating assingment group from script. Can you check hisotry of the incident and check value of assignment group , whether group value is getting filled first and post that value is getting cleared, based on that we can debug the issue