Setting Assignment Group based on Idea Category
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 10:19 PM
Hi @LL i need to set the assignment group and assigned to based on the Idea category.
I tried to search the category field in form layout but it is not present taking the value from the portal(server). I tried to create 1 business rule for fetching the value from the table -im_m2m_idea_category but it is not working.Table -im_m2m_idea_category mapped the idea and category table.
var gr = new GlideRecord('im_m2m_idea_category');
gr.addQuery('idea', current.short_description);
gr.query();
while(gr.next()) {
gs.addInfoMessage(current.short_description);
gs.addInfoMessage(gr.getValue('category_id'));
if(gr.getValue('category_id') == 'ITBM') {
current.assignment_group = "Default name1";
current.assigned_to = "TEST1";
current.update();
} else if (gr.getValue('category_id')== 'ITSM') {
current.assignment_group = "Default name2";
current.assigned_to = "TEST2";
current.update();
} else if (gr.getValue('category_id')== 'HR') {
current.assignment_group = "Default name3";
current.assigned_to = "Test3";
current.update();
}
}
})(current, previous);
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 04:14 AM
Let me try this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2024 10:04 AM
I tried the same script on Table -'im_m2m_idea_category' and fetch the value from idea table.
Now its working fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2024 10:19 AM
Okay, Great to hear that🤗, if my response helped you then please consider marking my solution as helpful and accept as well and close the thread , so that it could help the future readers.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 11:53 PM
Hello @Kumari Divya ,
Please give a try to the script below and let me know how it works for you.
(function executeRule(current, previous) {
var gr = new GlideRecord('im_m2m_idea_category');
gr.addQuery('idea', current.short_description);
gr.query();
while (gr.next()) {
var categoryId = gr.getValue('category_id');
gs.log("Idea: " + current.short_description);
gs.log("Category ID: " + categoryId);
if (categoryId == 'ITBM') {
current.assignment_group = "Default name1";
current.assigned_to = "TEST1";
} else if (categoryId == 'ITSM') {
current.assignment_group = "Default name2";
current.assigned_to = "TEST2";
} else if (categoryId == 'HR') {
current.assignment_group = "Default name3";
current.assigned_to = "Test3";
}
gs.log("Setting Assignment Group: " + current.assignment_group);
gs.log("Setting Assigned To: " + current.assigned_to);
current.update();
gs.log("Record updated successfully");
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket