Business Rule

-ooo-
Tera Contributor

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.  

1 REPLY 1

Karthiga S
Kilo Sage

Hi @-ooo- 

 

Try "else if" instead of multiple if.

 

Please mark it Correct and Hit Like if you find this helpful!

 

Regards,

Karthiga