- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 10:37 PM
I have written one onchange client script where i have declared one function also but getting warning for that function says "Move function declaration to function body root.".
Kindly check the below code where i am getting error for the function "checkValidMatchCommodityParse".
Please suggest how may i resolve that warning coming.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'NDA') {
g_form.clearValue('x_amex_sr_commodity_level_1');
g_form.clearValue('x_amex_sr_commodity_level_2');
g_form.clearValue('x_amex_sr_commodity_level_3');
g_form.clearValue('x_amex_sr_commodity_level_4');
g_form.clearValue('x_amex_sr_pu_commodity_code');
g_form.setDisplay('x_amex_sr_commodity_level_1', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_2', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_3', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_4', 'false');
g_form.setDisplay('x_amex_sr_pu_commodity_code', 'false');
} else if (newValue != 'NDA') {
g_form.setDisplay('x_amex_sr_commodity_level_1', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_2', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_3', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_4', 'true');
g_form.setDisplay('x_amex_sr_pu_commodity_code', 'true');
if ((g_form.getValue(x_amex_sr_contract_id)) != '' && (g_form.getValue(x_amex_sr_pu_commodity_code)) == '') {
var ga = new GlideAjax('SourcingEngagementUtils_2');
ga.addparam('sysparam_name', 'checkValidMatchCommodity');
ga.addParam('sysparam_contractid', g_form.getValue('contractid'));
ga.getXML(checkValidMatchCommodityParse);
}
function checkValidMatchCommodityParse(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('x_amex_sr_commodity_level_1', answer);
g_form.setValue('x_amex_sr_commodity_level_2', answer);
g_form.setValue('x_amex_sr_commodity_level_3', answer);
g_form.setValue('x_amex_sr_commodity_level_4', answer);
g_form.setValue('x_amex_sr_pu_commodity_code', answer);
}
//Type appropriate comment here, and begin script below
}
}
Solved! Go to Solution.
- Labels:
-
Connect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 10:46 PM
Hi,
it's a warning which you can ignore
If you wish you can update it as this; i.e. move the function outside onChange
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'NDA') {
g_form.clearValue('x_amex_sr_commodity_level_1');
g_form.clearValue('x_amex_sr_commodity_level_2');
g_form.clearValue('x_amex_sr_commodity_level_3');
g_form.clearValue('x_amex_sr_commodity_level_4');
g_form.clearValue('x_amex_sr_pu_commodity_code');
g_form.setDisplay('x_amex_sr_commodity_level_1', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_2', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_3', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_4', 'false');
g_form.setDisplay('x_amex_sr_pu_commodity_code', 'false');
} else if (newValue != 'NDA') {
g_form.setDisplay('x_amex_sr_commodity_level_1', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_2', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_3', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_4', 'true');
g_form.setDisplay('x_amex_sr_pu_commodity_code', 'true');
if ((g_form.getValue(x_amex_sr_contract_id)) != '' && (g_form.getValue(x_amex_sr_pu_commodity_code)) == '') {
var ga = new GlideAjax('SourcingEngagementUtils_2');
ga.addparam('sysparam_name', 'checkValidMatchCommodity');
ga.addParam('sysparam_contractid', g_form.getValue('contractid'));
ga.getXML(checkValidMatchCommodityParse);
}
//Type appropriate comment here, and begin script below
}
}
function checkValidMatchCommodityParse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('x_amex_sr_commodity_level_1', answer);
g_form.setValue('x_amex_sr_commodity_level_2', answer);
g_form.setValue('x_amex_sr_commodity_level_3', answer);
g_form.setValue('x_amex_sr_commodity_level_4', answer);
g_form.setValue('x_amex_sr_pu_commodity_code', answer);
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 10:46 PM
Hi,
it's a warning which you can ignore
If you wish you can update it as this; i.e. move the function outside onChange
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 'NDA') {
g_form.clearValue('x_amex_sr_commodity_level_1');
g_form.clearValue('x_amex_sr_commodity_level_2');
g_form.clearValue('x_amex_sr_commodity_level_3');
g_form.clearValue('x_amex_sr_commodity_level_4');
g_form.clearValue('x_amex_sr_pu_commodity_code');
g_form.setDisplay('x_amex_sr_commodity_level_1', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_2', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_3', 'false');
g_form.setDisplay('x_amex_sr_commodity_level_4', 'false');
g_form.setDisplay('x_amex_sr_pu_commodity_code', 'false');
} else if (newValue != 'NDA') {
g_form.setDisplay('x_amex_sr_commodity_level_1', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_2', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_3', 'true');
g_form.setDisplay('x_amex_sr_commodity_level_4', 'true');
g_form.setDisplay('x_amex_sr_pu_commodity_code', 'true');
if ((g_form.getValue(x_amex_sr_contract_id)) != '' && (g_form.getValue(x_amex_sr_pu_commodity_code)) == '') {
var ga = new GlideAjax('SourcingEngagementUtils_2');
ga.addparam('sysparam_name', 'checkValidMatchCommodity');
ga.addParam('sysparam_contractid', g_form.getValue('contractid'));
ga.getXML(checkValidMatchCommodityParse);
}
//Type appropriate comment here, and begin script below
}
}
function checkValidMatchCommodityParse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('x_amex_sr_commodity_level_1', answer);
g_form.setValue('x_amex_sr_commodity_level_2', answer);
g_form.setValue('x_amex_sr_commodity_level_3', answer);
g_form.setValue('x_amex_sr_commodity_level_4', answer);
g_form.setValue('x_amex_sr_pu_commodity_code', answer);
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader