Restricting fields on incident form based on view

Still Learning
Kilo Sage

Hello SN experts,

I have a very simple request to restrict the 'Urgency' and 'State' fields on the incident form when in Self Service ('ess') view. I have a dictionary override on those fields and also wrote an onLoad client script (unchecking the 'Global' checkbox and on view field = ess) to accomplish this but it is not working.  The fields are editable regardless of view. Can someone please tell me what I am doing wrong or if there is a better way to accomplish this. I've also tried to restrict those fields via UI Policy but that had no impact to the fields either.  

 

My Script: 

function onLoad() {
//By Default the 'urgency' and 'state' fields can be edited
g_form.setReadOnly('urgency', false);
g_form.setReadOnly('state',false);

//Check current view
var currentView = getView();
//If user is using 'ess' [Self Service] view then make 'urgency' and 'state' fields readonly
if(currentView == 'ess'){
	g_form.setReadOnly('urgency',true);
	g_form.setReadOnly('state',true);
	}
}

 

1 ACCEPTED SOLUTION

This problem happens because there is another UI Policy running on this table and it is making the fields editable again.

There are two alternatives to deal with this:
1- Check which UI Policy is conflicting and change its conditions.

2- Change the order of your Police UI to a high value like 999999, forcing it to be the last to run and consequently leaving the read-only field.

If my answer helped you, please mark my answer as helpful.

 

Vanderlei Catione Junior | LinkedIn

Senior ServicePortal Developer / TechLead at The Cloud People



View solution in original post

5 REPLIES 5

Vanderlei
Mega Sage

Hi @Still Learning 
I believe the best solution is to create a Police UI for this.
Just set the Global field to false and the view field will appear

Vanderlei_0-1697494316599.png

If my answer helped you, please mark my answer as helpful.

 

Vanderlei Catione Junior | LinkedIn

Senior ServicePortal Developer / TechLead at The Cloud People

Hello @Vanderlei 

Thank you so much for your reply. I've actually tried to get this to work via UI Policy but for some reason it does not work.  Please see the screenshot of my UI Policy below and the result of it on the incident form.  Should I script out the readonly fields? Or any other suggestions? Please advise.

Result of UI Policy_Self Service View.pngUI Policy.png

This problem happens because there is another UI Policy running on this table and it is making the fields editable again.

There are two alternatives to deal with this:
1- Check which UI Policy is conflicting and change its conditions.

2- Change the order of your Police UI to a high value like 999999, forcing it to be the last to run and consequently leaving the read-only field.

If my answer helped you, please mark my answer as helpful.

 

Vanderlei Catione Junior | LinkedIn

Senior ServicePortal Developer / TechLead at The Cloud People



@Vanderlei 

Thank you so much!! Changing the order to an increased value is what was needed to get it to work. Your solution worked.  Thank you so very much!!