- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 04:22 AM
Hi,
Any one help on below the requirement
I have created a field called "Brands Supported"on "Business Service" Table.When ever user updated "brand supported" field on parent table the same value has to update on "child table" field.If user want to update any value in child field should not allow only if the parent field value is empty then only has to allow the user to update the value in child field.
Thanks,
Lakshmi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 04:27 AM
Hi Dasetty,
You can achieve this by glideRecord to cmdb_rel_ci table where parent is the current business service and fetch all the child records and update the same.
Scenario 2 : If user want to update any value in child field should not allow only if the parent field value is empty then only has to allow the user to update the value in child field.
For this write a before update Business rule to check the parent Business service value and if this empty allow action otherwise current.setAbortAction(true);
Let me know in case you require more info.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 04:27 AM
Hi Dasetty,
You can achieve this by glideRecord to cmdb_rel_ci table where parent is the current business service and fetch all the child records and update the same.
Scenario 2 : If user want to update any value in child field should not allow only if the parent field value is empty then only has to allow the user to update the value in child field.
For this write a before update Business rule to check the parent Business service value and if this empty allow action otherwise current.setAbortAction(true);
Let me know in case you require more info.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 04:48 AM
Hi Sneha,
Thanks for your response!
I am new to CMDB so please explain with example script that would be more helpful.
Thanks,
Lakshmi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 05:53 AM
Hi Dasetty,
Scenario 1 :
var gr = new GlideRecord("cmdb_rel_ci");
gr.addQuery("parent",current.sys_id);
gr.query();
while(gr.next()){
var ci = new GlideRecord("cmdb_ci");
ci.get(gr.child.sys_id);
ci.Brands Supported = current.Brands Supported // replace this field with column name.
ci.setWorkflow(false);
ci.update();
}
Scenario 2 : If user want to update any value in child field should not allow only if the parent field value is empty then only has to allow the user to update the value in child field.
For this write a before update Business rule when Brands Supported is modified.
Script ---
var gr = new GlideRecord("cmdb_rel_ci");
gr.addQuery("child",current.sys_id);
gr.addQuery("parent.sys_class_name","cmdb_ci_service"); //Replace this with Business service class name
gr.query();
while(gr.next()){
if(gr.parent.Brands Supported != ""){
current.setAbortAction(true);
}
}
Hope this helps you.
Please validate the script and these are sample script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2019 04:50 PM
I have same requirement, it is similar to what ever you gave on above.it is related to db instances and server tables. those are linked in cmdb relationship table(like parent and child) you know every thing.
for example parent(cmdb_ci_db_instance), from this table each instance have have multiple child (cmdb_ci_server and cmdb_ci_db_mssql) records,this 3 tables have common field "checked" true/false type,when i checked the server table i want update the field on parent(cmdb_ci_db_instance) and child(cmdb_ci_db_mssaql_database).
for that i wrote below BR: "on server table"- it was perfectly updated the parent record(Test) when i checked the server(Databaseserver1), but what i want based on after updating the parent(Test) how to updated the individual db's i mean ChildDb2,ChildDb1,ChildDb records.
(function executeRule(current, previous /*null when async*/) {
var server = current.getValue('sys_id');// server record
var rel = GlideRecord('cmdb_rel_ci');
rel.addQuery('child.sys_id', server);
rel.addQuery('type','60bc4e22c0a8010e01f074cbe6bd73c3');
rel.query();
//gs.addInfoMessage('Test');
while(rel.next()){
if(current.u_qualified == true ){
//gs.addInfoMessage('Test3');
var dbInstance = new GlideRecord(rel.parent.sys_class_name);
var test = dbInstance.get('sys_id',rel.parent.sys_id);
dbInstance.u_qualified = true ;
dbInstance.update();
}
}
})(current, previous);
Could you please help me ASAP