I have set up a basic formula to check if a document has been added to a task before the task is completed. There are basically 2 pieces that would trigger the business rule error, if no document is added and if the after state value of the task status is complete (CPL or CPL:A).
What works: When I attempt to complete a task using the Percent Complete slider to 100% or change the status drop down to "Complete", I receive the error as expected - fantastic!
What is not working: If I close a task through the "Mark as Done" option in a task, the formula does not appear to recognize the change and does not flag the error. When i ran a Journal Report, it appears that a task that is closed via the Mark as Done button goes through a "DN" status and then moves into a "CPL" status. I have attempted to account for this in the formula but still does not seem to catch a task from being marked as done without a task.
Any ideas?
Formula:
IF(
{hasDocuments}=false &&
(CONTAINS("CPL", $$AFTER_STATE.{status}) || CONTAINS("DN", $$AFTER_STATE.{progressStatus})),
"**** Warning! **** You cannot set this task to complete until a document is attached"
)
Sample Images:
Closed via Status drop down or Percent Complete Slider - works as expected
Closed via Mark as Done and the task closing without document (error we are attempting to prevent)