How to write a client script to hide a UI Action (button) in Jakarta for a custom scoped application

Lon Landry2
Tera Contributor

After 8 hours; I am stumped trying to hide a button on a form.

I am aware of many solutions but none work in Jakarta for a custom scoped application.

It seems as though ServiceNow is moving away from custom scoped applications by limiting functionality and API availability.

Although I hope this is not the case...

I believe that I am limited to using the following APIs

  • GlideAjax
  • g_form
  • GlideDialogWindow

There is a condition, but I want to simply hide a button before moving on to more complicated tasks.

The end goal is hiding a button based on Session language settings.

The condition is based on browser settings (g_lang), but I could not figure out how to write an if / else statement in the UI Action Condition field.

This is an example of the (working) client script I use with g_lang:

function onLoad() {

    //Check session browser language settings

  //Display u_music_language field for English settings

  //Display u_music_idioma field for Spanish settings

if(g_lang == 'en'){

  g_form.setDisplay('u_music_language', true);

  g_form.setDisplay('u_music_idioma', false);

}

else if(g_lang == 'es'){

  g_form.setDisplay('u_music_language', false);

  g_form.setDisplay('u_music_idioma', true);

}

}

Thanks for your help and time,

1 ACCEPTED SOLUTION

You are very welcome. Thanks for participating in the community!


View solution in original post

14 REPLIES 14

Can you please create a new thread with the issue and share your personal DEV instance details or steps to reproduce.

Hi Pradeep,

 

Can you please share the solution with me too. I am facing kind of same issue.

Want to hide UI action button "Delete" when Knowledge article is in Published state.

 

 

Thanks

Sugandha

Hello Pradeep,

I wanted to hide the UI action buttons when the form is loading.

Engineers are clicking on the ui button when the form is loding and it casues to skip all the mandatory fields.

Can u please share me the code on which way we can restrict this?

i have used Loading method in UI macro, but still UI actions are clickable on teh form.

Can u please explain me how to rectify this issue?

 

Chuck Tomasi
Tera Patron

Realize that by using DOM, you put yourself at risk of this solution failing in future upgrades. Let the person making the requirement know the "true cost" of doing this. Yes, it's technically possible, but there is a cost of implementation, testing, maintaining, (potentially on every major upgrade). Verify with them - is this a MUST have or a NICE to have? (That should be asked for every requirement actually.)

Fortunately the project I am currently on allows me to work in the Global Scope. However to create anything for the ServiceNow store; everything must not be in Global Scope.  So I am not sure if it is worth tackling projects for ServiceNow store... 

Thanks for your time and input,

Lon