Banana Cake
Banana Cake

Reputation: 1242

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.

Upvotes: 0

Views: 193

Answers (2)

Md. Abdul Alim
Md. Abdul Alim

Reputation: 689

You can use return when condition fulfill if method is asynchronous. Like as

protected async override Task ExecutePlugin(IServiceProvider serviceProvider)
{
    int a = 0; // It's your conditioned value. Here 0 is sample value.
    if(a == 1)
   {
     return;
   }

}

But void method could not do this.

Upvotes: 1

Henk van Boeijen
Henk van Boeijen

Reputation: 7948

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.

Upvotes: 4

Related Questions