I have a requirement in one of the record producer, application/service variable is reference to bso

Archana23
Tera Contributor

I have a requirement in one of the record producer, application/service variable is reference to bso action table,if selected application is having the description in bso action table, it will auto populate in the description field in the form working as expected.

 

If application is not having any description and we have entered the test, if I change the application to other which was having the description the text which I entered is getting cleared and auto populating the description from the bso action table - working fine

 

If I change my mind and selected the application which was not having any description in the bso action table, the test which I entered should not get cleared. Is there any way to not to get cleared it.

Note: Not to use the hidden variable

 

Please suggest.

 

Archana23_0-1733830694290.png

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Archana23 

please share your script here

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

Archana23
Tera Contributor

client script:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }
    var gb = new GlideAjax('bsoUtils');
    gb.addParam('sysparm_name', 'getDescription');
    //gb.addParam('sysparm_act', g_form.getValue('u_action'));
    gb.addParam('sysparm_act', g_form.getDisplayValue('u_action'));
    gb.addParam('sysparm_desc', g_form.getValue('application'));
    gb.addParam('sysparm_ci', g_form.getValue('cmdb_ci'));
    gb.getXML(updateDesc);
}


function updateDesc(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
   
    if (answer != '') {
        g_form.setValue('description', answer);
    }
    //else
        //g_form.clearValue('description');
   
   
    //Type appropriate comment here, and begin script below

}
 
 
script include:
 
var bsoUtils = Class.create();
bsoUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

   
 getDescription: function() {
        var desc = null;
        var act = this.getParameter('sysparm_act');
        var bso = this.getParameter('sysparm_desc');
        var cii = this.getParameter('sysparm_ci');
        var gd = GlideRecord("u_bso_action");
        gd.addQuery("u_action", '=', act);
        gd.addQuery("u_ci", '=', cii);
        gd.addEncodedQuery('u_active=true^u_business_service_offering=' + bso);
        gd.query();
        if (gd.next()) {
            desc = gd.u_description;
        }
        return desc;
    },


       type: 'bsoUtils'


});