- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 01:54 AM - edited 08-12-2024 02:21 AM
Hello,
Could anyone please help me on this as i need to set the assignment group based on the subject line of incident.
I have created one table and there i stored subject and assignment group.I have created the inbound action for 'Create Incident'.
Below is the code.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 07:17 AM
Hi @Mansi roy
Try bellow refined script once and test:
// Set the caller and basic details from the email
current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
// Set incident state, notify and contact type
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
// Assign incident if specified in the email body
if (email.body.assign != undefined) {
current.assigned_to = email.body.assign;
}
// Set priority based on email importance
if (email.importance != undefined) {
current.priority = 1;
}
// Normalize the subject for searching
var subject = email.subject.toLowerCase();
// Query the subject group mapping table
var mapping = new GlideRecord('u_subject_group_mapping');
mapping.addQuery('u_subject', subject);
mapping.query();
if (mapping.next()) {
// If a mapping is found, set the assignment group
var assignmentGroup = mapping.u_assignment_group;
if (assignmentGroup) {
current.assignment_group = assignmentGroup;
} else {
gs.info('No assignment group found for the subject: ' + subject);
}
} else {
gs.info('No mapping found for the subject: ' + subject);
}
// Insert the new incident record
current.insert();
Also keep consider the point mentioned by Ankur, here I am assuming 'assignment group' field is reference field in your custom table.
I hope my answer helps you to resolve your issue, if yes mark my answer correct & helpful.
thank you
rajesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 12:53 AM
Last try, because for some reason you are ignoring my questions while I am trying to help you:
* why are you querying the incident table? Are you updating or creating?
* did you check on case sensitivity?
* why are you updating 'incident.assignment_group' instead of using 'current' like on the other field in the action?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 01:01 AM
Hello @Mark Manders,
This is my current script now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 01:06 AM
Is there a reason you are ignoring my questions? I am not asking them for fun, I am asking them to help you. You are also ignoring others with valid questions. Without knowing your setup (we can't look into your instance). How is your custom table setup? If the group is a reference, your 'setDisplayValue' won't work. But it seems you don't want to be helped for some reason.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 01:23 AM
Hello @Mark Manders,
I am sorry for confusion. I am not ignoring your question.
As you have asked here i am creating new incident from inbound action once the email is coming.
I tired incident.assignment_group as i glide record the incident table because i was not getting any result after glide recording the custom table. so i was setting like that. But now i am doing it by current.assignment_group. In my table two fields are string type only.
so i am using setDisplayvalue.
you can check the above code i paste. I hope you can get it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 01:29 AM
You should query to the group table, lookup through the name and set the sysID of the group.
You should also go back to your custom table and make the group field a reference field, because with it being a string, any name change on a group or typo on your custom record can cause this functionality to fail.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark