Setting Assignment Group based on Idea Category

Kumari Divya
Giga Guru

Hi @LL i need to set the assignment group and assigned to based on the Idea category.

KumariDivya_0-1706768282067.png

 

KumariDivya_1-1706768282068.png

 

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.

8 REPLIES 8

Pranav_Thanedar
Mega Sage

@Kumari Divya 

 

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

Hi @Pranav_Thanedar 

 

 Its not working.

Hi @Pranav_Thanedar 

(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. 

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