How to change the HTML that g_form.showFieldMsg generates in the DOM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2016 12:25 PM
We are interested in changing the way error and info messages are displayed on catalog items. We use g_form.showFieldMsg on many of our forms, and would like to find a way to change the HTML this function inserts into the DOM. We would like to have these messages inserted into the container to the right of the target input as an icon, that on-hover over the icon, would display the message. Is it possible to edit the components that g_form.showFieldMsg uses to render to the page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2016 01:11 PM
g_form is shipped with the ServiceNow platform and the styling for the field messages displayed inline to the fields comes from the platform. You can apply some dirty DOM hacks by writing global UI scripts and overriding g_form.showFieldMessage property.
Having said that, i would advise you to take this route. It is not good to manipulate any platform APIs. You will easily run into problems for getting it with all the fields. Platform API have been built over a period of time and are equipped to handle all the cases. All the these will be fully supported in case of an upgrades or other similar stuff whereas DOM hacks will most probably break in such cases.
Hope this helps.
Let me know in case you need more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 04:52 PM
Please see my tutorial / solution here: https://community.servicenow.com/community?id=community_article&sys_id=7197a729dba82f0023f4a345ca961...