Requirement of CMDB on reocrd producer

Community Alums
Not applicable

Hello Team,

 

I have one variable called "Application " which refers to cmdb_ci_service_discovered table .  on the selection of Application we need to populate the cis runs on that particular application in other variable called server cis .

 

I have written Script include for this However for me is showing all cis present in cmdb_ci_server table .

script include :- 

var Populate_servers_based_on_application_servicies = Class.create();
Populate_servers_based_on_application_servicies.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getServices: function() {

        var app_service = this.getParameter('sysparm_sys_id');
        //var arr = [];
        var ser = new GlideRecord('cmdb_rel_ci');
        ser.addQuery('parent.sys_id', app_service);
        //ser.addQuery('type', '60bc4e22c0a8010e01f074cbe6bd73c3');
        ser.query();
        if (ser.next()) {
            return ser.child;
        } else
        {
            return "Record Not Found";
        }

 


        //return sys_idIN+arr.join(',');
    },
    // //getenvironment:function()
    // {
    //      var env = new GlideRecord('cmdb_ci_serve')

    // }

    type: 'Populate_servers_based_on_application_servicies'
});

Client script :- 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    var ga = new GlideAjax('Populate_servers_based_on_application_servicies');

    ga.addParam('sysparm_name', 'getServices');

    ga.addParam('sysparm_sys_id', newValue);

    ga.getXML(getServices);

 

 

    function getServices(response) {

        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert(answer);
        //  var clearvalue; // Stays Undefined

 

        //   var returneddata = answer.evalJSON(true);

        g_form.setValue("server_ci", answer);

        // if (answer == 'Record Not Found') {
        //     g_form.setMandatory('server_ci', false);
        //     g_form.setMandatory('environment', false);
        // } else {
        //     g_form.setMandatory('server_ci', true);
        //     g_form.setMandatory('environment', true);

        // }

    }

}

Here I am able to populate the cis , but is shows all from the cmdb_ci_Server table .
My Requirement is only related cis needs to be populate on the selection of Application name,. 

1 REPLY 1

Mark Manders
Mega Patron

Can you please close this one and just proceed with the copy of this question you created: https://www.servicenow.com/community/developer-forum/requirment-of-cmdb-in-record-producer/td-p/3016...

Not sure why you created the exact same question only 2 hours after this one. Please allow people to take their time to respond. Having the same question asked multiple times and also on the same forum, just cause a waste of time for the people helping you and for yourself, because any solution provided in one question can also be provided by others in the other question. That doesn't help you if the solution is the correct one and it's a waste of effort.

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark