Client script doesnt work on SOW view

Sahar_Kaizer
Tera Contributor

Hi,

I created on change client script, it works on native ui but not in SOW although UI Type is ALL.

Sahar_Kaizer_0-1721899391410.jpeg

Thanks, 

Sahar.

1 ACCEPTED SOLUTION

Bhavya11
Kilo Patron

Hi @Sahar_Kaizer 

Please DO not use GlideRecord  in client script instead of that use GlideAjax and call script include.

 

Thanks,

BK

If this information proves useful, kindly mark it as helpful or accepted solution.

Thanks,
BK

View solution in original post

5 REPLIES 5

Bhavya11
Kilo Patron

Hi @Sahar_Kaizer 

 

try something like this 

 

1. create on-change client script and make changes the code according to yours

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
   var Check = new GlideAjax('GetLocationsByRegion');
Check.addParam('sysparm_name', 'getCI');
Check.addParam('sysparm_group', newValue);
 Check.getXMLAnswer(function(response) {
            if (response) {
                var dataUn = JSON.parse(response);
                var retUrl = dataUn.ts;
				g_form.setValue('urgency',dataUn.ts);
        } 
            
        });
    

}

 

 

Script include: client callable script include

 

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

    getCI: function() {
     
        var regionId = this.getParameter('sysparm_group');
        var gr = new GlideRecord('cmdb_ci_service');
        gr.addQuery('sys_id', regionId);
        gr.query();
        if (gr.next()) {
            var resultE1 = {};
            resultE1.ts = gr.business_criticality.toString();
			gs.log(resultE1);
            return JSON.stringify(resultE1);
        }
        return JSON.stringify({}); // Return an empty object if no record is found
    

    },
});

 

 

 

Please mark helpful & correct answer if it's really worthy for you.

 

 

Thanks,

BK

 

If this information proves useful, kindly mark it as helpful or accepted solution.

Thanks,
BK