- 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-19-2024 03:24 AM
Hi Aishwarya,
Have you tried this as an onChange script instead of onLoad?
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 03:37 AM
Yes, I tried to implement it using an 'on change' client script, but it's not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 03:25 AM
HI @Community Alums
the Workspaces are built with the new Next Experience UI Framework and here you are really restricted. For example, you cannot access anymore any HTML/DOM elements (g_form.getControl). So you have to comply to the official recommendations not to rely on DOM access/manipulation.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 03:39 AM
Ok, Thank you for the reply Maik.