- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 02:23 AM
Hi,
I created on change client script, it works on native ui but not in SOW although UI Type is ALL.
Thanks,
Sahar.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 02:44 AM
Please DO not use GlideRecord in client script instead of that use GlideAjax and call script include.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 03:24 AM
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