Using workflows to validate records to prevent creates, updates, assign and deletes

Business Scenario – I want to prevent a user creating an opportunity if the credit on hold status is set to yes of the potential customer.

I have many ways of doing this for example:

  • I could use a plugin
  • I could use some JavaScript
  • I could use a real-time workflow in CRM2013

The significance of using a workflow is that I now no longer need a developer to perform this development and if I want to the business rule later I can again without a developer. So how do I do this?

  1. Create a new process via Settings -> Processes
  2. Assign the process a name, associate to the entity the user will be creating that the validation will apply, in this case an opportunity
  3. Set the “Run this workflow in the background” to No
  4. ValidateProcess1
  5. Click Ok
  6. Now specify when the workflow should fire i.e. On create, change, assign, delete, in my scenario on Create
  7. NOTE: Not applicable to on create but is to the other options is when the workflow runs before or after the save event. For validation rules you always want to execute before the change is applied
  8. ValidateProcess2
  9. Now all you need to create is a simple condition in my case to check the related customer to the opportunity to see if the credit status is on hold and if it is prevent the save and display a message
  10. The key to a validation rule is Stopping the workflow as “Cancelled” this method prevents the save or action occurring on the record
  11. ValidateProcess3
  12. You will notice a new feature of real time workflows is the ability to define the status message of the reason for cancellation or success. In here we can specify how we inform the user on what to do next and is key to a validation rule.
  13. ValidateProcess4
  14. Now activate the workflow and test

Seeing the validation in action

So I now navigate to my account record and you can see that the credit on hold status is set to Yes.

ValidateProcess5

 

I click on the plus icon on the Opportunity grid and get presented with the quick create form. 

ValidateProcess6

I complete the details and save, I get presented with my nice status message, and the user can not create an opportunity.

ValidateProcess7

 

In summary …

Simple or complex validation rules can not be applied using workflows by non developers that enable the business to own the validation of the system. Very cool new feature and again shows you can do a lot before you need to customise!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s