Service catalog

ShaibaazFaheem
Tera Contributor

Hi Community! In the service portal, there is a field "approver" which is a reference field and I wanted to make it read only. Since the field is not a variable set, it is a custom field inside a custom Service Portal cart widget. Catalog UI policy/client script will not work. How to make the field read only? Detailed answer would be highly appreciated.

4 REPLIES 4

Brad Bowman
Mega Patron

If it's a field, treat it like any other field.  Since it's a custom field you'll have to find the table it's on, then you can make it read only at the dictionary level, or with a table-level UI Policy or Client Script.

Tanushree Maiti
Kilo Patron

Hi @ShaibaazFaheem 

 

To make an approver reference field read-only in a custom Service Portal cart widget, the most effective method in ServiceNow is to use AngularJS directives within the HTML template or manipulate the field via the Client Controller.

 

Refer: https://www.servicenow.com/community/developer-forum/make-all-fields-read-only-in-custom-widget/m-p/...

 

https://www.servicenow.com/community/developer-forum/read-only-field-on-service-portal-only/m-p/1773....

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

ChallaR
Giga Guru

Hi @ShaibaazFaheem ,

 

Because the field is in a custom Service Portal widget, make it read‑only in the widget itself:

  • Add ng-disabled="true" (for reference pickers)
    or
  • Add ng-readonly="true" (for input fields)

 This makes the field read‑only in the portal.

Most custom portal widgets use sn-record-picker for reference selection.

Example (HTML):

<sn-record-picker
  field="c.approverField"
  table="'sys_user'"
  display-field="'name'"
  value-field="'sys_id'"
  ng-model="c.data.approver"
  ng-disabled="true">
</sn-record-picker>
That makes it read-only (disabled) in the UI.

Conditionally read-only (e.g., based on state/role)

<sn-record-picker
  field="c.approverField"
  table="'sys_user'"
  display-field="'name'"
  value-field="'sys_id'"
  ng-model="c.data.approver"
  ng-disabled="c.isReadOnly">
</sn-record-picker>
And in Client Controller:
c.isReadOnly = true; // or condition
// e.g. c.isReadOnly = (c.data.ritm_state == 'approved' || !c.data.canEdit);

 Catalog UI Policies / Client Scripts won’t work here.

 For full safety, block updates using an ACL or Business Rule.

Create a write ACL on the field (or table) to deny updating the approver field.

  • Table: your table (ex: sc_cart_item / sc_req_item / your custom table)
  • Field: u_approver (your custom field)
  • Operation: write
  • Script condition: allow only specific roles OR deny always if required.
answer = gs.hasRole('admin');

 

Thanks,

Rithika.ch

Ankur Bawiskar
Tera Patron

@ShaibaazFaheem 

screenshots please

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader