How to hide a field based on incident table state in Service Portal widget?

Naina3
Kilo Contributor

Hi,

I want to hide a field when the state of incident table is either Resolved or Closed in portal. Can anyone tell me how to do that?

 

Thanks in advance!

4 REPLIES 4

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi Naina,

The best option is to create UI Action on portal side then you could follow below approach:

Server side script:

data.hideButton = true;
if(data.table == 'tableName' && data.f._fields.state.display_value == "Choice Display Value"){
data.hideButton = false;
}

 

HTML Template:

<button   ng-hide="data.hideButton">

Hope this will fit your need!

Please, remember to mark Correct or Helpful if you find my response useful.

Cheers
Alberto

Hi Alberto,

Thanks for your response! I tried this but unfortunately it is not fetching the value of incident_state field, undefined, is what I am getting as the value of this particular field, due to which the if condition is not working properly. Do you have a way to fetch the value of incident_state field?

Hello Alberto,

 

I am trying to use the above code for hiding a button on portal for a specific condition ie. when company is Hogarth then it should hide the button but not able to get what to put in condition. Below sharing code snippet can you please help with this ?

 

Screenshot 2024-03-01 at 11.59.52 AM.png

Thanks

VigneshMC
Mega Sage

If you are using "form" widget, then use client script to hide it.

Thanks