- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 05:11 AM
Hi Team,
Can anyone please help me on the below query how can we achieve this in ServiceNow.
In Incident if i selected ci is related to Application server class in that i have 3 Custom fields and those are reference field to the group table. For example if i selected ci as server it should check weather field1 is having group or not if group is there the incident should assign to that group, if not i should check second field like this i need to set a auto assignment logic for incident.
Thank You.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 11:07 AM
Here is the corrected code.
Make it run in BUsiness rule After Incident is inserted. Basically on table : incident
(function executeRule(current, previous) {
if (current.cmdb_ci !='' && current.cmdb_ci.sys_class_name='cmdb_ci_service_auto') {
var groupField1 = current.cmdb_ci.u_reference_3;
var groupField2 = current.cmdb_ci.u_reference_4;
var groupField3 = current.cmdb_ci.u_reference_5;
if (isGroupValid(groupField1)) {
current.assignment_group = groupField1;
}
else if (isGroupValid(groupField2)) {
current.assignment_group = groupField2;
}
else if (isGroupValid(groupField3)) {
current.assignment_group = groupField3;
}
current.update();
}
})(current, previous);
function isGroupValid(group) {
if (group) {
var groupGR = new GlideRecord('sys_user_group');
if (groupGR.get(group)) {
return true;
}
}
return false;
}
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 05:29 AM
Hi @nikhitha24
When does it needs to assigned to said group? when incident is created or anytime during incident lifecycle like if CI changed after sometime on incident then new AG should be added as per CI?
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 09:51 AM
When the incident record is created from a record producer i have a variable to select the CI based on that CI it need to be assigned to that group.
I have written Before Business rule when the record is insert and the table is record producer for this but it is not working.
Please refer the code below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 11:07 AM
Here is the corrected code.
Make it run in BUsiness rule After Incident is inserted. Basically on table : incident
(function executeRule(current, previous) {
if (current.cmdb_ci !='' && current.cmdb_ci.sys_class_name='cmdb_ci_service_auto') {
var groupField1 = current.cmdb_ci.u_reference_3;
var groupField2 = current.cmdb_ci.u_reference_4;
var groupField3 = current.cmdb_ci.u_reference_5;
if (isGroupValid(groupField1)) {
current.assignment_group = groupField1;
}
else if (isGroupValid(groupField2)) {
current.assignment_group = groupField2;
}
else if (isGroupValid(groupField3)) {
current.assignment_group = groupField3;
}
current.update();
}
})(current, previous);
function isGroupValid(group) {
if (group) {
var groupGR = new GlideRecord('sys_user_group');
if (groupGR.get(group)) {
return true;
}
}
return false;
}
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 12:12 AM
Thank you Sushantmalsure, It is working now.