Make form fields readonly and also editable on service portal form

Avdhoot
Tera Contributor

Hi 

I have requirement in service portal there is incident detail form.

In that form i have to make all fields readable and and only one field editable it will applicable to all user.

for example watchlist field should be editable in incident form and all other fields should be readable only. And watchlist person and caller should able to edit . 

can some one help me with this? 

3 REPLIES 3

Bert_c1
Kilo Patron

Hi Avdhoot,

 

You can start here: https://docs.servicenow.com/search?q=UI%20policies

 

A 'UI Policies' can be used to do that. Check those in your instance.

 

Markus Kraus
Kilo Sage

A UI Policy alone will not help you here.

I'd do the following:
1.) Create new Form View (e.g. "sp_reduced"): Configure -> Form Layout -> View Name -> New... -> "sp_reduced"

MarkusKraus_1-1688068265731.png

 

2.) Create a UI Policy which makes all fields readonly (note: Set "Global = false" and "View = sp_reduced")

MarkusKraus_0-1688068228502.png

3.) Create a view rule (Advanced = True, Type = Browser) which only runs on the serviceportal and will force the view to "sp_reduced"

(function overrideView(view, is_list) {

	if (gs.action.getGlideURI().toString().startsWith('api/now/sp')) {
		// force view on portal
		answer = 'sp_reduced';
	} else {	
		answer = null;
	}

})(view, is_list);

 

Andrew_TND
Mega Sage
Mega Sage

You want to use a UI policy if the read only is dependent on other values, however if this isnt the case you can go into the variable and set it as "read only".

Please mark as helpful or if its resolved the issue CORRECT!