If condition in the Business Rule

san1989
Giga Guru

I have one custom table(u_custom) with three fields. 

Fields are company(reference to core_company), life cycle status(drop down list with five values) and product model.

It is related list to the product model table. Company field(reference) has seven records (one parent company and six child companies).

Note: I can select multiple records of (u_custom) table to the single product model record(each model).

My requirement is, if I select the parent company with any life cycle status, I should not be able to select the same life cycle status for the other child companies for the product model.

Can you please help me with the logic in Business Rule.

Thanks

1 ACCEPTED SOLUTION

(function executeRule(current, previous /*null when async*/) {

// Add your code here
var gr = new GlideRecord("cmdb_ci_service");
gr.addquery('model_id',current.model_id);
gr.query();
while(gr.next()){

var grp=gr.support_group.getDisplayValue();


if(grp.indexOf("CAB Approval") == 0 && gr.service_classification.indexOf("Business Service") != 0){
gs.addInfoMessage("test the first if condition");

}


else if(grp.indexOf("CAB Approval") !=0 && gr.service_classification == current.service_classification){
current.setAbortAction(true);
}

}

})(current, previous);

 

//support_group is refernece field i believe so you need to use getDisplayValue() to get the name else it will always give you sysid

View solution in original post

6 REPLIES 6

My thoughts are on a reference qualifier but that don't apply to a Related list.

You could perhaps solve this with some messing around with ACL and some creative thinking. 

But not a solution I would recommend or even try to develop.
With all the other issues it comes with. 

Perhaps just for the LOLs if so. 

smcdonaldaz
Tera Guru

You need to use an advanced reference qualifier:

https://community.servicenow.com/community?id=community_question&sys_id=34c6cf65db1cdbc01dcaf3231f96199d&view_source=searchResult