I believe you could add a Validation rule to 'Validate on Update' in the Incident Business Object like this:
$(Status != "Closed" && Status != "Resolved" ||
"$(Status == 'Completed' || Status == 'Cancelled' || Status == 'Rejected')"))
1 of 1 people found this helpful
Indeed you can, here is the out of the box Validation rule we are employing.
$(Status != "Closed" && Status != "Resolved" || IsTrueForAllChildren("Incident#", RecId, "Task#Assignment.Rev3", "$(Status == 'Completed' || Status == 'Cancelled' || Status == 'Rejected')"))
I appreciate that this is going back a while but I'm wondering if you phan10ms or anyone else ever worked this out?
One of the issues that our analysts raise with me most often is that if they choose the Resolve Incident button they can enter all the resolution details and press save before the check whether there are any outstanding tasks is done. This then means that they lose all the information they've written in the resolution. Obviously in a perfect world they wouldn't forget to complete the tasks first, but the world isn't perfect and this is something even I'm guilty of from time to time (or about once a month if I'm honest!).
The solution phan10ms is attempting to implement would be the optimal solution as it would ensure that the resolution can't even be activated until all the tasks are completed. The use of the out of the box expression triggers when the status change is saved and not when it is initially triggered (i.e. when the button is pressed), if it could be triggered when the button is pressed instead, that might be a suitable workaround.
You can add a counter to the incident record to count open tasks something like a before save rule should work. You can then base the quick action disable rule based upon this field being > 0 or not.
You could also have a new field on incident where a calculated rule runs. That calculated rule can evaluate IsTrueForAllChildren and return a boolean value. Your Resolution disable rule can evaluate against this new field.
The concern I have in both cases would be that if you have a field to evaluate whether there are incomplete tasks outstanding you would then have to initiate a change and save on the Incident so that the field value recalculates and triggers the Resolve button being activated.
I believe there is an option in the Calculated business rule to always calculate which should cover your concern. I don't have immediate access to my environment so i cannot test this at the moment. I will attempt this in my sandbox in the next hour or so.
If you complete a task from memory it will update the incident anyway (last modified date time), so you do not need to trigger a change on the incident for the rule to trigger, you may need to refresh the incident for the button to activate but that would be easy to test.
Ok so I have this working
- Create a new field on the incident object: OpenTaskCounter - Number (4,0) upto 1000 tasks possibly overkill
- Add a before save business rule:
$(ChildFold("Incident#", RecId, "Task#Assignment.IncidentAssocTaskAssignment", $(if Status not in ("Completed", "Cancelled", "Rejected") then 1 else 0), "+"))
- Add your resolve ticket button to the form
- Add a button visibility rule:
$(OpenTaskCount > 0)
If the open task count is greater than 1 the resolved button is disabled, if you have an open task and complete it as the task saves it will make the resolve button available.