The CreatorCon Call for Content is officially open! Get started here.

Requirement trigger

Community Alums
Not applicable

I have one requirement on Change _ request table:- 

when the user click on request for approval button , check approval affected CIs/services and condition are if approval group and Owned by is Available trigger approval for approval group and owned by  , if approval group is not available and if owned by is null then check if managed by group is available then it trigger approval to managed  by .

 

actually we need to achieve this  through Business rule , previously we are trying workflow it takes time .

 

I created business rule change_request after insert . 

 

answer = [];
var a = current.sys_id;
var gr = new GlideRecord('task_ci');
gr.addEncodedQuery('task=' + a);
gr.query();

var approvalGroup = null;
var ownedBy = null;
var managedBy = null;

while (gr.next()) {
    var ap = gr.ci_item.change_control;
    var owned = gr.ci_item.owned_by;
    var mana = gr.ci_item.managed_by;

if (ap != null && approvalGroup == null) {
        approvalGroup = ap;
    }
   
    if (approvalGroup == null && owned != null && ownedBy == null) {
        ownedBy = owned;
    }
   
    if (approvalGroup == null && ownedBy == null && mana != null && managedBy == null) {
        managedBy = mana;
    }
}

 

Please let me know if this we can achieve . Help me to resolve this through business rule. 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

you want this on click of button then why to use BR?

Why not add the code in the UI action itself?

what debugging have you done so far?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hello Ankur @Ankur Bawiskar ,

 

firstly we tried  make version 2 and applied tried to write workflow code , but later the requirement changes , already  request approval button OOTB UI action is der but that is not for this requirement , please let me know how we can achieve this   on UI action , or can we create UI action on change_request table . if it is yes then how we can achive this .

 

PLease let me know , it will be really helpful for me if  we can achieve this through UI