Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

SK Chand Basha
Tera Sage

I had a requirement where we needed to hide a UI Action from the top form header and display it only at the bottom of the form.

 

UI Action:

When a UI Action is enabled as a Form button, ServiceNow automatically renders it in both the header and the bottom sections of the form.

 

SKChandBasha_0-1767335127850.png

 

Client Script:

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    g_form.addInfoMessage("TEST1");

	/*
	This line selects the UI Action button with the data-action-name value test from the form’s HTML using ServiceNow’s jQuery ($j)
	*/

	var ans = $j('[data-action-name="test"]')[0].hide();

	g_form.addInfoMessage("Answer: " + ans);

    }

 

Disable Isolate Script:

Turn off script isolation (set Isolate Script = false) so the client script can interact with the form’s DOM elements.

 

What happens when made true?

When Isolate script = true, ServiceNow:

  • Runs the script in a sandboxed scope
  • Prevents access to:
    • Global objects
    • DOM
    • window
    • $j / jQuery
  • Allows only safe APIs like:
    • g_form
    • g_user
    • GlideAjax

SKChandBasha_1-1767335635921.png

 

UI Action on the Target:

 

SKChandBasha_2-1767335670231.png

 

Result:

 

SKChandBasha_3-1767335723763.png

 

Happy Learning!!

 

 

 

 

Comments
Vishnu-K
Kilo Sage

Thanks for sharing.

Ankur Bawiskar
Tera Patron

@SK Chand Basha 

Direct DOM manipulation is not recommended. Instead, you should guide the customer on best practices and explain how the platform is intended to be used by end users.

Not applicable

This is not a good practice, in fact this requirement should not be considered.
The availability of button at the top and bottom is a valuable feature in case the form is too big or the agent has to view the related records in the related list.

The bottom buttons provides the ease to agents.

 

I would emphasise the customers to align with the OOB features and reduce the technical debt wherever possible.

the script works for you now, but will it work forever as ServiceNow updates its versions?? I dont think so.


SK Chand Basha
Tera Sage

Hi @Community Alums , @Ankur Bawiskar 

I completely agree with you. I followed the article mentioned below, and there appears to be an issue in the code.

I just wanted to correct the below article.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0697296

Version history
Last update:
‎01-02-2026 05:43 AM
Updated by:
Contributors