Configure form on Service Portal reference field popup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2018 08:12 AM
Hello,
I have a requirement to lock down form fields on some reference field pop-ups in our Service Portal. All fields need to be read only, and certain fields need to be hidden from non-admin users. In this example, I have a catalog item with a reference variable to the sys_user table.
On the form I can select the info icon for "Who is this request for?" to display fields for the user record.
I'm using a client script that sets all form fields to read only, then checks the current user's roles and hides all certain fields for non-admin users. The script runs onLoad for the UI type Mobile/Service Portal. Below is an example of my code.
Here is an example of my code:
function onLoad() {
//Set fields to read only.
g_form.setReadOnly('<field name>', true);
g_form.setReadOnly('<field name>', true);
etc.....
var uRole = g_user.hasRole('admin');
//If user isn't an admin hide these fields.
if(uRole == false){
g_form.hideRelatedLists(true);
g_form.setDisplay('<field name>', false);
g_form.setDisplay('<field name>', false);
etc.....
}
}
I would like to also remove the Save button from this form, but I'm unsure of the best way to do this. Is it possible to capture the element for the button in my client script and hide it from there?
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 07:36 AM
Hi
Yes you can do it by DOM manipulations (document.getElementById()) but servicenow doesn't reccomend this approach.
You can refer the below link which will help you achieve your query.
Mark correct if it helps.
Regards,
Omkar Mone
www.dxsherpa.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2018 09:13 AM
Hi Omkar,
Thanks for responding! I read through the link you provided, and I saw a response that looks like it's heading in the right direction for what I'm trying to accomplish.
I tested this in the Page Editor for sc_cat_item and I was able to hide the Submit button. However, I want to apply this on the reference popup for the reference field that is on the catalog item form. I don't see Reference Popup, sys_popup or anything similar to that the Page Editor. Where would I need to go to apply this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2018 10:47 PM
Hi
Sorry for late reply.
Maybe you can go through this link.
Mark correct if it helps.
Regards,
Omkar Mone
www.dxsherpa.com