Client Script suggestion - Field Message

Rob Sestito
Mega Sage

Hey SN Comm,

I am looking to throw a little field message right under Assignment Group (just for our Employee Relations COE).

I was thinking of doing an onLoad client script - with conditions...

IF Assignment Group field is empty, show message

IF Assignment Group is NOT empty, hide message

Any suggestions on how to accomplish? Is onLoad Client Script the best way to do this? If not, what would be better?

Maybe a UI message box that the user can click OK / Cancel to in order to dismiss the message..?

Thanks in advance!

-Rob

What I did so far with an onLoad: (is this the right path?)

function onLoad(){

if('assignment_group','==',"");

g_form.showFieldMsg('assignment_group','Be sure to select Assignment Group first, then select the Assigned To person','info');
g_form.showFieldMsg('assignment_group','Employee Relation Teams are as follows: HR Employee Relations Level 1, HR Employee Relations Level 2, HR Employee Relations Level 3','info');

 

1 ACCEPTED SOLUTION

James Gragston
Tera Guru

Hey Rob S.

It's best practice to avoid Client scripts that run when the form loads. You can use a Display Business Rule instead since it avoids the browser having to parse and work with the form right when the user is waiting for it to display. This becomes more true the more fields you have on your form. However, if you're not having any efficiency issues, there's not necessarily a problem with using an Onload Client script. If you go with this option, make sure you use the g_form.hideFieldMsg('<field_name>') as the FIRST method you run if you're going to be using info messages. This will clear any lingering messages if the end user decides to refresh the page.

In this case though, I would go ahead and use a Display Business rule and just set the condition field as follows:

'assignment_group - is empty'

This way, the business rule runs and shows your message when this condition is true. From there, you just have to script the message:

go to the 'actions' tab and just write your message. No scripting required!

View solution in original post

8 REPLIES 8

And it was a 'display' business rule? If so, also make sure that it's assigned to the right table and that the condition is <field_name> - is empty. Those are the only two problems I foresee. I tried this solution before I answered your enquiry and I didn't have an issue.

Yeah, here is what I have:

find_real_file.png

find_real_file.png

And still no message appears.

Thanks,

-Rob

James Gragston
Tera Guru

I would recommend troubleshooting any other business rules that may be firing and interfering with your form. You should navigate to Session Debug > Debug Business Rule (Details). Once this is enabled, go back to your form and at the bottom of the screen will be all of the business rules that are firing when you load the form. It should look like the following:

find_real_file.png

In the above example, 'Get VIP flag' & 'Room field prompt' are the only business rules that fired when this form loaded. If you see any business rules that are firing other than the one you're currently working on, I would investigate those and see how they are altering your form. I would also click the context menu on the form and navigate to Configure > Client Scripts to see what Client Scripts are acting on your form as well.

Thanks for your suggestion!

Kid you not, right after I ran the debug session, the Display BR was showing the message at the top of the form. All I wanted to do was bang my head on my desk... lol

No reason why this could have not been showing last night when we were building this.. lol

just shrug my shoulders and move on - hahaha

Thanks for the help and suggestion something other than using a Client Script. My next step(s) will be that I need to speak to the manager of the Employee Relations Groups COE - and see which message they would prefer.

Appreciate the help!

-Rob