- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 07:58 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 12:47 PM
(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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 08:48 AM
I don't understand your requirements.
Can you please develop your question a bit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 12:36 PM
(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()){
//if(gr.support_group == "CAB Approval" && gr.service_classification != "Business Service"){
if(gr.support_group.indexOf("CAB Approval") == 0 && gr.service_classification.indexOf("Business Service") != 0){
gs.addInfoMessage("test the first if condition");
//if(gr.support_group != "CAB Approval" && gr.service_classification == current.service_classification){
if(gr.support_group.indexOf("CAB Approval") !=0 && gr.service_classification == current.service_classification){
current.setAbortAction(true);
}
}
}
})(current, previous);
My requirement if CAB Approval support group has service classification other than the Business Service, the service classification should not repeat for the other support groups for the current model.
if the support group is 'CAB Approval' and service classification is 'Technical Service' then any other support group should not have the service classification as 'Technical Service'.
but the above code is not working as expected. Can you please correct the code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 12:47 PM
(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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2018 08:54 AM
I don't know of a way to have the Related List - Edit - List Collector dynamically change like that. Maybe you could do a BR that would prevent the update and give an alert when that occurs instead?