Show variable help text based on the condition

ramwons
Kilo Expert

Hello,

I want to show help text based value selected in a previous variable.

Variable1 -> Yes/No

Variable2.

If Variable1 is set as YES then the help text of Varible2 should be "Test 1".

If Variable1 is set as NO then the help text Variable2 should be "Test 2".

I have created a UI policy and in script I use g_form.showFieldMsg.

But whenever I change the value in Variable1 the both the help text are displaying one down the another. Help text is not getting cleared based on the value selected.

Best Regards,

Ram

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you cannot set dynamic help text directly

if you are using showFieldMsg then just when your onchange client script starts you need to hide the field message using hideFieldMsg

you should use client script when scripting is involved

please share your script

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi @ramwons 

In order to change the variable help text you need DOM manipulation which is not recommended. Instead if you have to do please refer to the below link:

Updating variable help text dynamically?

If I have answered your question, please mark my response as correct and helpful so that this thread can be closed and others can be benefited by this.

Thank you very much

Cheers
Alberto

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you cannot set dynamic help text directly

if you are using showFieldMsg then just when your onchange client script starts you need to hide the field message using hideFieldMsg

you should use client script when scripting is involved

please share your script

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thanks Ankur.

just another quick question. is it possible to bring a line to next line within using showFieldMsg?

Best Regards,

Ram

 

Hi,

you can try to use \n character

var message = 'message1\nmessage2';

g_form.showFieldMsg('variable', message,'info');

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader