Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Why Onchange Script runs while reloading the page

Linga Suvetha1
Tera Contributor

Hi,

I have written an onchange client script code to populate some info message when some conditions are met.

But the info messages are populated while reloading the page.

 

//Script

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var cat = g_form.getValue('category');
var sub = g_form.getValue('subcategory');
var bs = g_form.getValue('business_service');
var grp = g_form.getDisplayBox('assignment_group').value;
var usr = g_form.getValue('assigned_to');
if (cat == 'hardware' && sub == 'broken device (unusable)' && bs == '026bab04db3044102db740a505961975' && grp.startsWith('TCS') && usr == '') {
g_form.addInfoMessage(getMessage('breakfix'));
}
//Type appropriate comment here, and begin script below
}

3 REPLIES 3

Danish Bhairag2
Tera Sage

Hi @Linga Suvetha1 ,

 

Can u replace the code with below n check if it still runs?

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
var cat = g_form.getValue('category');
var sub = g_form.getValue('subcategory');
var bs = g_form.getValue('business_service');
var grp = g_form.getDisplayBox('assignment_group').value;
var usr = g_form.getValue('assigned_to');
if (cat == 'hardware' && sub == 'broken device (unusable)' && bs == '026bab04db3044102db740a505961975' && grp.startsWith('TCS') && usr == '') {
g_form.addInfoMessage(getMessage('breakfix'));
}
//Type appropriate comment here, and begin script below
}

 

Thanks,

Danish

 

Hi Danish,

Thanks for the reply..But the issue is still there..

The onchange script still popup the message while loading the page

Hi @Linga Suvetha1 ,

 

Can u share the snip of ur whole code plz i mean the whole page of onchange script & also the popup message which is appearing.

 

Thanks,

Danish