Hide Button in SOW on change of field value

SM123
Tera Expert

Hi All,

I have a yes/ no choice field called "Fix is applied" in problem form I'm Trying to hide "Resolve" Button in SOW on on change of field value. But i'm unsuccessful. could anyone please help me figure it out? I have gone through below community pages by which i can be able to hide the button in default view but not sow. 

https://www.servicenow.com/community/developer-forum/can-we-hide-custom-button-using-onchange-client...

 

Thank you

4 REPLIES 4

GlideFather
Tera Patron

Hi @SM123 

 

to that UI Action you might need to add some condition when to display it.

 

It would be something similar as adding following example to the existing condition:

&& g_form.getValue('your_field') == 'true'

 

Let me know your progress

 

EDIT: corrected a typo (g_gorm > g_form)

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


wojasso
Giga Guru

Hi @SM123,

The workspace action bar in Service Operations Workspace does not react to `g_form`/`g_gorm` commands. The buttons you see in SOW are declarative UI actions, and their visibility is controlled by the server‑side **Condition/Visibility script** on the UI action record – they are not dynamically shown or hidden by on‑change client scripts.

A better approach is to update or clone the **Resolve** UI action with a condition that checks your field. For example:

* **Condition on the UI action**: `current.fix_is_applied != true` – the button will only be available when **Fix is applied** is false.
* If you only want this in the workspace, create a separate Declarative Action (UI action of type *Workspace*) on the table and set a *Visibility condition script* similar to:

```
(function() {
// hide the action when Fix is applied is true
return !state.record.fix_is_applied;
})();
```

In both cases the button will be hidden for records where the field is set to *Yes*. If the user changes the field in the workspace, the action list is only refreshed on reload, so there is no supported way to hide it dynamically with a client script.

`g_gorm` methods can hide form fields or sections, but they do not control the action bar. To hide actions in SOW you must rely on the UI action’s condition or a Declarative Action.

Hope that helps! Let me know if you have any questions.

Hi @wojasso ,

I already have separate declarative action for SOW button please check the attached image. But I'm looking for on change of field value if there is a way to hide a button like before saving/updating the form.

malika123_0-1753381104594.png

 

Thank You 

wojasso
Giga Guru

Might be on my side, but I can't see the attached image. 
It shows with a "triangle"/warning icon like it wouldn't be loaded properly 😞