Need help with script to show info message on select box

Sam198
Mega Guru

Hi all,

I need to show info message when an option is selected from the select box:

select box variable: Department (department)

Value for the select box optioin - '2' (Text - 'IT')

 

Script onChange:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;

}

//Field message that will inform the user what will happen when they pick this selection
if(g_form.getValue('department')=='2'){
g_form.showFieldMsg('department','If the issue is urgent please see Service Desk','info');

}
else{

g_form.hideFieldMsg("department");

}

 

}

 

 

1 ACCEPTED SOLUTION

Chalan B L
Giga Guru

What you r trying to write is correct 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;

}

//Field message that will inform the user what will happen when they pick this selection
if(newValue ==2){
g_form.showFieldMsg('department','If the issue is urgent please see Service Desk','info');

}
else{

g_form.hideFieldMsg("department");

}

 

}

View solution in original post

4 REPLIES 4

Chalan B L
Giga Guru

What you r trying to write is correct 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;

}

//Field message that will inform the user what will happen when they pick this selection
if(newValue ==2){
g_form.showFieldMsg('department','If the issue is urgent please see Service Desk','info');

}
else{

g_form.hideFieldMsg("department");

}

 

}

Thanks for the reply Chalan, but it still does not show the info message, is it because the selection box is under "department" variable? Can we show on the selection choice value which is 2 in this case?

 

Hello Sam,

 

Just tried in my PDI and the above code is working

 

Onchange Client script 

onchange of Title to testValue then it is displaying infomessage in description

find_real_file.png

govinddas
Tera Expert

Hi Sam,

 

We have tried replicating your issue and below are the assumptions taken:

We assume you have used the catalog client script to show the field message(client script).

Small correction in the else part that instead of having the field name in double quotes "g_form.hideFieldMsg("department"); " can you please change to single quote

g_form.hideFieldMsg('department');

 

Please provide filed values (choices)