Multiple UI Policies on Same Field Not Working as Expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2018 11:13 AM
NowI have multiple UI Policies on the same field, and I cannot get them to work the way that I want. It is my understanding that the one I want to "override" (or take precedence over the other should be the larger Order number).
So, here is my original UI Policy that was working fine. Basically, it hides my approver field from sc_req_item when the approver field is empty. This UI Policy has an order number of 100.
Now, I am trying to add a new UI Policy. There is one situation in which the Approver field is empty that I want to show it. Not only do I want to make it visible, but I also want to make it editable (basically, in part of a workflow, if the field is blank, the RITM is being assigned to a group that needs to populate it). The order number I use for this is 200. However, it doesn't work. It does, in fact show the field in this scenario, but it is Read-Only so I cannot edit (and I am in the group it is being assigned to). Here is what that UI Policy looks like:
I did also search for any other UI Policies on this field, and could not find any.
Can anything see what I am doing wrong? How can I accomplish my goal?
Thanks
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2018 11:17 AM
In situations like this, I would suggest staying with a single UI Policy, then use scripts to handle your rules. Or you could scrap the UI Policy and use an onload client script to handle it instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2018 11:29 AM
OK. I have never written a UI Policy script before (I have written scripts for other things, but not this). Do you have a link to a script of this kind that I may be able to refer to (I find that in writing scripts, I am often tripped up by the minor differences in how each one requires that you refer to fields and variables, and what is required in each one).
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2018 12:24 PM
You can do a UI Policy Script similar to a Client Script, so you'd use g_form.getValue('field_name'), g_form.setReadOnly('field_name',true or false), g_form.setDisplay('field_name',true or false);
In the case of UI Policies, the top box is if the condition is true and the bottom box is if the condition is false. So, in your condition, just have approver is empty. Then in the true UI policy script, something like:
if(g_form.getValue('short_description') == 'value you are looking for'){
g_form.setDisplay('u_approver',true);
g_form.setReadOnly('u_approver',false);
}
else{
g_form.setDisplay('u_approver',false);
}
Then in the false script, it would be just
g_form.setDisplay('u_approver',false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2018 12:36 PM
Just to make sure I follow this completely, since we have the scrip, we then wouldn't have anything in the "UI Policy Actions" section at the bottom, right?