For many years, we have been practicing the usage of triggers to perform custom validations by the usage of addError in before triggers.
And let us admit, even though coding at times sound easy, not everyone can do it.
Here is once such use case that can be achieved using a flow and avoid writing any piece of code.
Consider the following use case:
You have a Case record where one of your agents work on and there are a number of tasks that the agent creates related to that case. However, you would like the task to never be created when the case is closed and would want the system to prompt the agent why it cannot be done.
So what is all that you need to get this done?
- A custom field (Checkbox)
- A validation rule
- An automated flow
We would create a custom field (checkbox) on Task and a Validation Rule. The validation rule would trigger when this new field is set to true.
We will let our automated flow trigger during the task creation, look for the status of the related case and try setting this new field to true.
How to get it done:
Now create an autolaunched flow, and double click on the Start node.
Now create a resource –> variable of type Record –> let us call it caseRecord and save.
Drop the “Get Records” on the screen and configure as below:
Tip: Please ensure that you query out the IsClosed field, without it you cannot access it’s value in the next step.
Now add a “Decision” element to the screen to check if the case is already closed.
And now time for the last step, add the “Assignment” element to set this new field to true.
The Final Version: