Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Value not set in refernce field, but getting the value from SI

Ankita9793
Tera Contributor

Hi All,

 

I am facing issue in setting value in this 'eim_id' field which is a reference field. 
but, i'm getting this value in the script include response, eim_sys_id from SI is mapped to 'eim_id' from CS.

 

Alert response : 

data===>{"u_eim_application_id":"BA0005205","eim_sys_id":"Regulatory Datamart CN"}

 

Client script :

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    g_form.clearValue('eim');
    g_form.clearValue('eim_id');
    var eimDetails = newValue.split("_");
    var eimID = eimDetails[0];

    var gaSet = new GlideAjax('HashiCorpClientHelper');
    gaSet.addParam('sysparm_name', 'getEIMDetails');
    gaSet.addParam('sysparm_eimNumber', eimID);
    gaSet.getXMLAnswer(processResponseData);
   ShowHideLoaderCatalog();
}

function processResponseData(answer) {
   ShowHideLoaderCatalog('hide');
    try {
        if (answer) {

            var data = JSON.parse(answer);
            alert("data===>" + JSON.stringify(data) ); //data===>{"u_eim_application_id":"BA0005205","eim_sys_id":"Regulatory Datamart CN"}
          
            g_form.setValue('eim', data.eim_sys_id);
            g_form.setValue('eim_id', data.u_eim_application_id); //Value is not set 
            console.log("data.u_eim_application_id===>" + data.u_eim_application_id);
            console.log("data.eim_sys_id===>" + data.eim_sys_id);
        }
    } catch (ex) {
        console.log("HashiCorp Vault - Self Service::processResponseData  ex===>" + ex);
    }
}

SI :

    getEIMDetails: function(eimID) {

        eimid = this.getParameter("sysparm_eimNumber");
        var data = {};
 
        var greim = new GlideRecord('cmdb_ci_business_app');
        greim.addQuery("u_app_instance_id", eimid);
        greim.query();
        if (greim.next()) {
            data.u_eim_application_id = greim.number.toString();
            data.eim_sys_id = greim.name.toString();
            gs.info('ANKITA eimname >> ' + data.u_eim_application_id);
        }
        return JSON.stringify(data);
    },
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@Ankita9793 

so what's not working?

is field/variable "eim_id" is referring to table "cmdb_ci_business_app" then update line as this

data.eim_sys_id = greim.sys_id.toString();

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron

@Ankita9793 

so what's not working?

is field/variable "eim_id" is referring to table "cmdb_ci_business_app" then update line as this

data.eim_sys_id = greim.sys_id.toString();

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader