UI Macro checkbox with text

Lucy10
Tera Contributor

Hi All.

Im a newbie to servicenow and using ui macros.

I want to have a ui macro with a checkbox and text to it like "I acknowledge the above statement". This will be on a request form and the check box needs to be mandatory.

So far im not able to get the check box and text on the same line and also how would I invoke the check box to be mandatory?

Any suggestions would be much appreciated.

Thanks,

Lucy

4 REPLIES 4

Nate23
Mega Guru

Lucy,



Can I ask why not create a new field on the Request form of type checkbox instead of creating one through a ui macro? Using ServiceNow native field/data type includes upgrade support and out of the box functionality like being able to use a serviceNow field type in ui actions and ui policies.


Lucy10
Tera Contributor

Thanks for the your reply and suggestion, the reason i thought I would use a UI macro because the text will also contain a hype link to a policy page


Consider using Configure Label on the field (Configuration item shown here)



find_real_file.png



In the form, set the URL...



find_real_file.png



Your label then becomes a hyperlink with a ? icon as an extra indicator.



find_real_file.png



Setting the help field may also work, but isn't quite as elegant. Your choice. Reference here: Field Label Help - ServiceNow Wiki


Chuck Tomasi
Tera Patron

Hi Lucy,



Why do you need a UI macro? Why not just use a standard true/false field? UI macros require custom Jelly coding which is going to be difficult to create and maintain.



The short answer to the mandatory thing is, you cannot make a checkbox mandatory because mandatory checks to see if the field has a value. Checkboxes always have a value (true and false - and false/off/unchecked IS a value.) You would need to use a client script to check if the box is checked and throw a warning if it is not. This is most commonly used in an onSubmit client script to check the status of that field and abort if it is not checked.



Docs: Client Scripts


Docs: GlideForm


Client Script Best Practices - ServiceNow Wiki