Need to check if the CI has downstream relationship if yes then show a pop up

Arun Priya
Tera Contributor

If the install status Retire under the update Existing CI, Check if the Mapped Application Service has any downstream relationships if yes then it must pop-up. I have used  script include and called through client script. The below code works but it checks in the table level. In table some times the record is not found but in the CI it has the relationship. Can anyone suggest me any alternative way to check if the CI has downstream relationship?

Script include: 

var CheckChildExist = Class.create();
CheckChildExist.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkCI: function() {
var ciName = this.getParameter('sysparm_ciName');
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('parent', ciName);
gr.query();
if (gr.next()) {
return 'true';
} else
return 'false';
},
type: 'CheckChildExist'
});

Client Script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
 
    //Type appropriate comment here, and begin script below
    var ciname = g_form.getValue('name1');
    // alert(ciname);
    var ga = new GlideAjax('CheckChildExist');
    ga.addParam('sysparm_name', 'checkCI');
    ga.addParam('sysparm_ciName', ciname);
 
    ga.getXMLAnswer(function(response) {
        if (response == 'true') {
            if (g_form.getValue('install_status')== '7') {
                alert("You need to submit  a new request");
                g_form.clearValue('name1');
            }
 
        }
    });
}
0 REPLIES 0