How to prevent a record to be created in a plugin?

Posted on Posted in MS CRM 2015

Let’s say we have a situation where we create a record by running a workflow ‘ABCWorkflow’ but we want to check some kind of criteria/conditions and if it meets that criteria then create that record otherwise cancel transaction.

Unfortunately in our case we can not check criteria in workflow so only option we have is to run workflow but place checks in plugin.

In this case we could create a custom action ‘ABCAction’ and in that action call a plugin ‘ABCPlugin’ and then create a workflow and in workflow we could call our custom action ‘ABCAction’ and if results are as expected then it should create a record otherwise it should not.