GET Operation with status PENDING or EXECUTING

What product/components do you use and which version/fix level are you on?

Cumulocity IoT 10.13

What are you trying to achieve? Please describe it in detail.

Is there a way to get an operation by status PENDING or EXECUTING with one call?
Example, that is not working:

const filter: object = {
      deviceId: this.moId,
      fragmentType: 'custom_type',
      status: 'PENDING|EXECUTING',
      pageSize: 1
const op: IOperation | undefined = (await this.operationService.list(filter)).data[0];

Is there a way through REST API
maybe? so far I’ve tried:

"message": "Incorrect argument:  : No enum constant com.cumulocity.model.operation.OperationStatus.PENDING|EXECUTING"
"message": "Incorrect argument:  : No enum constant com.cumulocity.model.operation.OperationStatus.PENDING,EXECUTING"
"message": "Incorrect argument:  : No enum constant com.cumulocity.model.operation.OperationStatus.PENDING EXECUTING"
"message": "Incorrect argument:  : No enum constant com.cumulocity.model.operation.OperationStatus.PENDINGEXECUTING"

I’m pretty sure there is not. Not officially anyways and a custom query for example is ignored (just tried).

Care to elaborate a bit why this would be beneficial? Apart from just being nice? I guess you could try to work with custom Fragments if you really need to, i.e. manually create a fragment when am operation goes to PENDING.

Yeah, that what I found as well. It looks like there is no way to actually get an operation in either of two states in one call.
I have a piece of functionality, that should block any other operation creation if there is one scheduled or executing already. I will create an Aha ticket for it

This functionality is missing right now, but an Aha idea created here
Update: Aha idea invalidated by GET Operation with status PENDING or EXECUTING - #6 by Nick.Ponomar

Actually you can just delete the status parameter which will give you all operations with ALL status.
You have to filter in the result list for pending and executing operations though.

Another approach is by just sending two requests: One for PENDING and one for EXECUTING. If either both of them containing something you have the result you are looking for.

There is another way to get that resolved with a revert parameter. General guideline from Cumulocity is that all operations has to be executed in order created on the platform. So getting one or a couple of latest operations works. Here is a code snippet for it:

const filter: object = {
      deviceId: this.moId,
      fragmentType: 'custom_type',
      dateFrom: '1990-01-01',
      revert: true,
      pageSize: 1
    const op: IOperation | undefined = (await this.operationService.list(filter)).data[0];
    if (op && (op.status == OperationStatus.EXECUTING || op.status == OperationStatus.PENDING)) {
      // business login goes here

This will return a list of at most one operation with the newest operation of the specified type for the specified device. If it is in status PENDING or EXECUTING then there is an operation, if it doesn’t exists or if it is in status SUCCESSFUL or FAILED then there is no ongoing operation. This works for single devices because devices are responsible to execute operations in order.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.