Validate Mandatory Fields on GlideRecord update?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2018 07:32 PM
I am working on a requirement where when a release task is closed, it should automatically update the parent release to the next state. I have a business rule that runs on the release task after update. The tricky part is, it should not update if the mandatory fields on the parent release are not all populated. I am making the fields in question mandatory with UI policies on release table.
One idea I had, was to use data policies instead of UI policies to enforce mandatory, as they run on the server side. But one issue I encountered is the annoying 'Data Policy Exception' messages that show up on the page, often multiple times and I can't seem to figure out how to get rid of them. I tried a try-catch around the GlideRecord update but that didn't work. Also as a more critical issue, the state flow automatic script I have for the next state seems to run regardless of the update to the next state failing.
The only other idea I have is to check all the mandatory fields field by field in the business rule. This would not be a clean solution as I have multiple UI policies with different conditions whose logic I would have to copy into the business rule, and also if the UI policies were ever changed in the future the business rule would have to be updated with it which seems difficult to maintain.
So is there a cleaner solution to this problem?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2018 08:24 PM
So it sounds like the feedback I have received is that I should validate the mandatory fields on the release are populated before creating the release task. Is there a way to do this without making all the fields mandatory in the first state of a release? My requirements are that certain fields are not visible/mandatory until a certain state is reached. But if I could require the mandatory fields in a given state first, then create the release task in that state, they might be ok with that solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2018 08:42 PM
I believe, yes, we can have the mandatory field visible on the form as per the given state, get the values in that and then created the release task. In that way we should not be worry to check which fields we have validate at what state before creating the release task and deciding what to do with that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2018 09:06 PM
So how should I create the task? Unfortunately I don't know of any way to have a business rule with the condition 'no mandatory fields are empty'. So would I have to check each field one by one? This was the solution I was hoping to avoid. Many of my UI policies have multiple conditions, such that if field x is not empty, field y is mandatory.