
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 03:12 AM
Does anyone have any idea why this would happen?
Thank you in advance!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 03:16 AM
Sorry for not posting earlier. I forgot to post the answer at that time. below are the raw code -
Thank You.
var load_data = {
'u_reference_1': [{
'value': "" }],
'company': [{
'value': ""}],
'u_city': [{
'value': ""}],
'u_state_province': [{
'value': ""}],
'category': [{
'value': "" }],
'subcategory': [{
'value': ""}],
'u_item': [{
'value': ""}],};
function onLoad() {
var unregister = g_form.onUserChangeValue(user_selected_field_value);
var short_description = g_form.getValue('short_description');
if (short_description != "") {
var split_short_description = short_description.split("-");
var sity_province = split_short_description[3].replace(/[()]/g, '').split(',');
load_data['u_reference_1'][0].value = split_short_description[0];
load_data['company'][0].value = split_short_description[1] + "-" + split_short_description[2];
load_data['u_city'][0].value = sity_province[0];
load_data['u_state_province'][0].value = sity_province[1];
load_data['category'][0].value = split_short_description[4];
load_data['subcategory'][0].value = split_short_description[5];
load_data['u_item'][0].value = split_short_description[6];}}
function user_selected_field_value(filedvalue, originalValue, newValue) {
if (filedvalue == "company") {
var run_after_company_selected = setTimeout(function() {
update_company_details(newValue);}, 1000);
}
if (filedvalue == "u_reference_1") {
if (newValue) {
g_form.setValue('company','');
load_data['company'][0].value = " ";
var parentAccount = g_form.getReference('u_reference_1', parentAccount_fun);
} else {
load_data['u_reference_1'][0].value = " ";
concate_data(); }
} else { if (filedvalue != "company") {
if (load_data.hasOwnProperty(filedvalue)) {
load_data[filedvalue][0].value = newValue;
concate_data();}}}}
function parentAccount_fun(parentAccount) {
load_data['u_reference_1'][0].value = parentAccount.name;
concate_data();}
function update_company_details(compeny_sysid) {
var script_include = new GlideAjax('global.incident_shortdescription_details');
script_include.addParam('sysparm_name', 'getDetails');
script_include.addParam('Account_sysid', compeny_sysid);
script_include.addParam('Paccount_sysid', g_form.getValue("u_reference_1"));
script_include.getXML(function(response) {
var account = response.responseXML.documentElement.getAttribute("answer");
var data = account.split(",");
load_data.company[0].value = data[0];
load_data.u_reference_1[0].value = data[1];
load_data.u_state_province[0].value = g_form.getValue('u_state_province');
load_data.u_city[0].value = g_form.getValue('u_city');
concate_data(); });}
function concate_data() {
var category = load_data['category'][0].value;
var u_item = load_data['u_item'][0].value;
var u_city = load_data['u_city'][0].value;
var u_state_province = load_data['u_state_province'][0].value;
var company = load_data['company'][0].value;
var u_parent_account = load_data['u_reference_1'][0].value;
var subcategory = load_data['subcategory'][0].value;
var testmy = u_parent_account + " - " + company + " - (" + u_city + "," + u_state_province + ")" + " - " + category + " - " + subcategory + " - " + u_item;
g_form.setValue('short_description', testmy);}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2024 03:58 AM
Is your client script working on Service Operations Workspace?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:19 AM
Have you found the solution? We have 3 level categories: Top category, category and subcategory. We write client script: onChange, to display subcategory. It works fine in incident form on platform, but it doesn't work on SOW.
In script onChange, we get subcategories by Ajax call and display it. I have checked "Isolate script" CheckBox too.
1. Ajax call - get subcategories
2. Function below to display drop-down. Data isn't loaded to the drop-down
function populateIssue(response){
g_form.clearOptions('u_issue');
var answer = response.responseXML.documentElement.getAttribute("answer");
var answer1 = JSON.parse(answer);
g_form.addOption('u_issue','','-- None --',0);
for(var i = 0; i < answer1.length; i++) {
g_form.addOption('u_issue', answer1[i], answer1[i], i+1);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:28 AM
Hi @Community Alums ,
Set the "Isolate Script" field on the client script to "True" and that should help resolve the issue.
Please refer to below articles:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1220159
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0960131
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:33 AM
Thank you for reply.
I have Set the "Isolate Script" field on the client script to "True"
I notice SOW doesn't support "response.responseXML.documentElement.getAttribute("answer");"
Does anyone know how to get the return from GlideAjax?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 03:16 AM
Sorry for not posting earlier. I forgot to post the answer at that time. below are the raw code -
Thank You.
var load_data = {
'u_reference_1': [{
'value': "" }],
'company': [{
'value': ""}],
'u_city': [{
'value': ""}],
'u_state_province': [{
'value': ""}],
'category': [{
'value': "" }],
'subcategory': [{
'value': ""}],
'u_item': [{
'value': ""}],};
function onLoad() {
var unregister = g_form.onUserChangeValue(user_selected_field_value);
var short_description = g_form.getValue('short_description');
if (short_description != "") {
var split_short_description = short_description.split("-");
var sity_province = split_short_description[3].replace(/[()]/g, '').split(',');
load_data['u_reference_1'][0].value = split_short_description[0];
load_data['company'][0].value = split_short_description[1] + "-" + split_short_description[2];
load_data['u_city'][0].value = sity_province[0];
load_data['u_state_province'][0].value = sity_province[1];
load_data['category'][0].value = split_short_description[4];
load_data['subcategory'][0].value = split_short_description[5];
load_data['u_item'][0].value = split_short_description[6];}}
function user_selected_field_value(filedvalue, originalValue, newValue) {
if (filedvalue == "company") {
var run_after_company_selected = setTimeout(function() {
update_company_details(newValue);}, 1000);
}
if (filedvalue == "u_reference_1") {
if (newValue) {
g_form.setValue('company','');
load_data['company'][0].value = " ";
var parentAccount = g_form.getReference('u_reference_1', parentAccount_fun);
} else {
load_data['u_reference_1'][0].value = " ";
concate_data(); }
} else { if (filedvalue != "company") {
if (load_data.hasOwnProperty(filedvalue)) {
load_data[filedvalue][0].value = newValue;
concate_data();}}}}
function parentAccount_fun(parentAccount) {
load_data['u_reference_1'][0].value = parentAccount.name;
concate_data();}
function update_company_details(compeny_sysid) {
var script_include = new GlideAjax('global.incident_shortdescription_details');
script_include.addParam('sysparm_name', 'getDetails');
script_include.addParam('Account_sysid', compeny_sysid);
script_include.addParam('Paccount_sysid', g_form.getValue("u_reference_1"));
script_include.getXML(function(response) {
var account = response.responseXML.documentElement.getAttribute("answer");
var data = account.split(",");
load_data.company[0].value = data[0];
load_data.u_reference_1[0].value = data[1];
load_data.u_state_province[0].value = g_form.getValue('u_state_province');
load_data.u_city[0].value = g_form.getValue('u_city');
concate_data(); });}
function concate_data() {
var category = load_data['category'][0].value;
var u_item = load_data['u_item'][0].value;
var u_city = load_data['u_city'][0].value;
var u_state_province = load_data['u_state_province'][0].value;
var company = load_data['company'][0].value;
var u_parent_account = load_data['u_reference_1'][0].value;
var subcategory = load_data['subcategory'][0].value;
var testmy = u_parent_account + " - " + company + " - (" + u_city + "," + u_state_province + ")" + " - " + category + " - " + subcategory + " - " + u_item;
g_form.setValue('short_description', testmy);}