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

Can you add an alert before the field message to confirm that the code is getting executed.

 

also, Can you confirm you are using this on start_date field and not work_start

-Anurag

If the showMsg field replaced by alert . It's working.

 

Yes, it written on start_date.

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Can you share how you are using this? In a (Catalog) Client Script? onChange perhaps?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

Find the 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
}
}
}

Allen Andreas
Administrator
Administrator

Hello,

Unfortunately, more information is needed. You've mentioned the "alert is working fine"...where did you place that alert? It's not in your code included below?

You've provided the client script, now I'm assuming we'll need the script include...?

So we're getting it, piece by piece. Please provide more information about what alert statements you've used and where.

We need to verify what is coming back from your script include to see why the FieldMsg isn't working because as others have mentioned, the syntax looks correct.

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


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