Search code examples
c#.netdynamics-crmcrm

Cancel System Job Entity from Plugin


I have async plugin. I need to cancel his system job (change satus reason to CANCELLED) if let's say a=1. How can I do it?

protected override void ExecutePlugin(IServiceProvider serviceProvider)
{
    var a = 1;
    if(a == 1)
   {
    //cancel the job
   }

}

Try to write me also +- code, if you can, thank you.


Solution

  • It is not possible to cancel asynchronous plugins. From within a plugin you can only end execution with the status success or failed (when an exception is thrown).

    Only workflows can be canceled.