Evaluate UI Policies in a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2011 11:30 AM
Is it possible to write a script that evaluates UI policies for the current record, returning true if all mandatory fields are completed and false if mandatory fields are blank?
I need to make the "State" field on my "Change Request" form read-only, and require users to click a button (UI Action) to advance the ticket to the next state. However, I only want the button to be visible if all UI policies are satisfied. We have made a lot of extensions to our Change Request form, and there are a lot of UI policies. I am now faced with the prospect of duplicating all this logic in the "Condition" field of my UI Action. Is there an easier way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2011 01:40 PM
I'd also echo Tony's warning about excessive or non-performant UI Policies / Client Scripts, you can also use
to determine whether all mandatory fields are populated, see below:
g_form
var hasNoMissingFields = g_form.getMissingFields().length == 0;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2011 04:03 PM
First off, be careful with "a lot of UI policies", this can really bog down the user experience. Be sure you minimize/optimize them.
Second, ignore what was here and go with Chris's
call instead. Much smarter way.
g_form.getMissingFields().length
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2011 07:26 AM
g_form.getMissingFields() is cool.
However, I was originally looking for was a server-side equivalent of this function. I was going to go with a server UI action because I have some other processing that needs to happen when the state changes. If I go with a client UI action then I need to either (a) move the other processing into the client script, or (b) split the processing between client UI action and a business rule. Also, I think the client script can only modify fields that appear on the form and are editable by the user, whereas the server script has no such limitation.
If there were a server equivalent of this function, then I could just add the following condition to my server UI action and I would be home free.
getMissingFields(current).length == 0
Any thoughts?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2011 02:39 PM
I don't think the server side is going to be able to detect that... The user isn't going to be able to submit the form if mandatory fields are blank?????