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
01-31-2024 11:02 PM
The assignment group and assigned to are reference fields, could you please try sys_id's of those instead of name?
Check and let me know if there are still issues.
Regards,
Pranav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 12:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 01:27 AM
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('im_m2m_idea_category');
gr.addQuery('idea', current.sys_id);
gr.query();
while(gr.next()) {
gs.addInfoMessage(current.sys_id);
gs.addInfoMessage(gr.getValue('category_id'));
if(gr.getValue('category_id') == 'category_sysid') {
current.assignment_group = 'Group_sysid';
current.assigned_to = "TEST1";
current.update();
} else if (gr.getValue('category_id')== 'category_sysid') {
current.assignment_group = 'Group_sysid';
current.assigned_to = "TEST2";
current.update();
} else if (gr.getValue('category_id')== 'category_sysid') {
current.assignment_group = 'Group_sysid';
current.assigned_to = "Test3";
current.update();
}
}
})(current, previous);
With this code its update the assignment group when idea created from portal and submitted in list and when we update the record in form view it will update with assignment group and assigned to.
But not updated the assignment group when it is submitted from portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 02:03 AM
Hello @Kumari Divya ,
Can you try with the below code once?
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('im_m2m_idea_category');
gr.addQuery('idea', current.getValue('sys_id'));
gr.query();
while (gr.next()) {
gs.addInfoMessage(current.getValue('sys_id'));
gs.addInfoMessage(gr.getValue('category_id'));
var categorySysId = gr.getValue('category_id');
if (categorySysId == 'category_sysid1') {
current.assignment_group = 'Group_sysid1';
current.assigned_to = "TEST1";
current.update();
} else if (categorySysId == 'category_sysid2') {
current.assignment_group = 'Group_sysid2';
current.assigned_to = "TEST2";
current.update();
} else if (categorySysId == 'category_sysid3') {
current.assignment_group = 'Group_sysid3';
current.assigned_to = "Test3";
current.update();
}
}
})(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