Business Rule to create approvers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 04:47 AM
Hi, I am having one customization to create approvals through business rule. I have created a change request through catalog task. That change request is having one custom field u_group_approver. This field needs to be filled on the basis of change type i.e. standard, normal or emergency.
1. If change type - Normal
u_group approval = Ateam
2. If change type - Normal
u_group approval = Bteam
3. If change type - Normal
u_group approval = Cteam
Now the approval should create for the assigned team members and if anyone would approve then it should create a change task and assigned to different teams based to database locations on catalog task form.
We cannot use workflow due to certain reasons. Can anyone help to do it with business rule.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 05:45 AM
Hello,
For 1st scenario:adding approvers
You can write "After Insert" BR rule on change_request table.
add the below script:
if(current.type=='standard')
{
current.u_group_approver = 'sys_id of Ateam';
current.update();
}
if(current.type=='Normal')
{
current.u_group_approver = 'sys_id of Bteam';
current.update();
}
if(current.type=='Emergency')
{
current.u_group_approver = 'sys_id of Cteam';
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 05:56 AM
Hello,
For 1st scenario:adding approvers
You can write "After Insert" BR rule on change_request table.
add the below script:
if(current.type=='standard')
{
current.u_group_approver = 'sys_id of Ateam';
current.update();
}
if(current.type=='Normal')
{
current.u_group_approver = 'sys_id of Bteam';
current.update();
}
if(current.type=='Emergency')
{
current.u_group_approver = 'sys_id of Cteam';
current.update();
}
var gr = new GlideRecord('sysapproval_approver');
gr.initialize();
gr.approver= current.u_group_approver;
gr.sysapproval=current.sys_id;
gr.state='requested';
gr.insert();
For 2nd Scenario:
You can create an after update business rule on the Approval table.
Add below condition:
previous.state == 'requested' && current.state == 'approved';
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.parent = current.request_item;
gr.short_description = 'QA Testing Task';
gr.request_item = current.request_item;
gr.insert();
Mark my response as Helpful and correct as applicable.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 06:57 AM
Hi Mahak... Thank you so much for your help. I am able to generate the task now. But do you know how we can generate multiple change tasks and assign them to diff groups?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 08:48 AM
Hello,
Please use below script:
if(current.operation()=='insert')
{
var taskk=new GlideRecord('sc_task');
for(var i=0;i<2;i++){
taskk.initialize();
taskk.caller_id=current.caller_id;
if(i == 0){
taskk.assignment_group.setDisplayValue("ABC");
}
if(i ==1){
taskk.assignment_group.setDisplayValue("DEF");
}
taskk.insert();
}
}
Mark my response as Helpful and correct as applicable.
Thanks