showFieldMessage & ErrorBox msg nor working

Naveen87
Tera Guru

Hey Guys, 

 

Im trying put an error or info message under the field. But it's not reflecting.

g_form.showFieldMsg("start_date","Selected Date is in past, Select a valid date","info",true);

suggest me something here

1 ACCEPTED SOLUTION

Hi,

Was that not happening before?

Actually, you know what...hmm...try clearing the field first THEN do your field message.

g_form.setValue('start_date', ''); // Setting the variable as empty
g_form.showFieldMsg('start_date', "Test 123", 'error');

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

17 REPLIES 17

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

There is no issue in the script or syntax.

How and where are you using this?

-Anurag

-Anurag

Hi Anurag,

I'm using on change_request table on start_date.

If user select's a past date from current.

Alert is working fine but i wish to show msg under the particular .

Suggest me some things.

Errorbox would also work.

Please provide syntax , if possible

Michael Fry1
Kilo Patron

That line looks correct so maybe it's how you have your client script setup? Can you share full script?

Hi Fry, 

Find the complete script below,

 

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

//Type appropriate comment here, and begin script below
var change = g_form.getValue('u_change_type');
//if(newValue != '')
if(newValue == 'major'||'minor');


{
var ga = new GlideAjax('ConfirmDate');
ga.addParam('sysparm_name', 'chkCurrDate');
ga.addParam('sysparm_date',g_form.getValue('start_date'));
ga.getXML(NewParse);
}
function NewParse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == 'false'){
g_form.showFieldMsg("start_date","Selected Date is in past, Select a valid date","error",true);
g_form.setValue('start_date', '');
g_form.setValue('end_date','');// Setting the variable as empty
}
}
}
 

suggest me