
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 04:17 AM
Hi,
I need to add a UI action on the cmdb_ci_service table that is checking if the record has >0 childs related to serivce offerings ... and wonder about the easy way of doing this ...
I know there is somethin like ".hasChildren(current.sys_id) ... but this is not specific to service offerings ... so how to specify my "children" here ... ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 10:37 PM
You need to configure a script include
function checkIfParent() {
var gr = new GlideRecord("cmdb_rel_ci");
gr.addQuery("parent", current.sys_id);
gr.query();
return gr.hasNext()
}
In your UI Action, put condition as checkIfParent()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 05:29 AM
Hi,
try below code in ui action to check has related child records.
var parent1=current.sys_id;
var gr = new GlideRecord("cmdb_rel_ci");
gr.addQuery("parent", parent1);
gr.query();
var childs=gr.getRowCount();
if (childs>0) {
gs.addInfoMessage("child count"+childs);
}
else
gs.addInfoMessage("child count"+childs);
current.update();
action.setRedirectURL(current);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 06:42 AM
... I was looking for a condition it set in the condition field for ui action ... so the UI Action should not show up in case no relevant childs ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 10:37 PM
You need to configure a script include
function checkIfParent() {
var gr = new GlideRecord("cmdb_rel_ci");
gr.addQuery("parent", current.sys_id);
gr.query();
return gr.hasNext()
}
In your UI Action, put condition as checkIfParent()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 10:29 PM