Camunda-External-Task-Client-js multi instance collection help

Hi

I’m trying to create a working scenario where an external event processed by the camunda-external-task-client-js lib passes an array of objects (containing invoices for example) to a multi-instance which would then process each invoice individually.

Firstly is it possible :slight_smile:

If possible === true then …

I do get an error indicating that item is not a collection. I just don’t know how to resolve it.

Can someone point me in the right direction? :blush:

1 Like

The variable you send back from the worker need to be a collection and then it will loop around from each element in that collection.

Hi Niall. Been watching you train this week in the the HPI course I’m busy with :slight_smile: Thanks !

How do I create a collection when using Javascript ? :slight_smile:
I’m doing something like this…

const collection = [{},{},{}]

const myVariable = new Variables();
processVariables.set('item', collection)

taskService.complete(task);

The error I receive is notifying me that item is not of type collection.

Hi @Shaun_Botsis Were you able to resolve this issue. ? I am also stuck with a similar thing.

Hi, I figured it out and was able to solve it.

My Json collection looks like something below

[ {
    "projectName": "Sample Project",
	
	"designerId": "12345",
	
	"summary": [
        {
            "attribute": "Test 123",
            "passfail": "pass",
            "successCount": "15",
            "total": "15"
        },
        {
            "attribute": "Test 456",
            "passfail": "fail",
            "successCount": "14",
            "total": "15"
        }
	]
	
   },
   
   {
    "projectName": "Sample Project 2",
	
	"designerId": "65457",
	
	"summary": [
        {
            "attribute": "Test 456",
            "passfail": "pass",
            "successCount": "15",
            "total": "15"
        },
        {
            "attribute": "Test 879",
            "passfail": "fail",
            "successCount": "14",
            "total": "15"
        }
	]
	
   }
   
]

External client js code where the result is JSON from the top.

let processVariables = new Variables();

processVariables.setTyped('sowcanradDataCompareList' ,{

  type: "json",

  value: result,

  valueInfo: {}

});

await taskService.complete(task,processVariables);

This how I configured my multi-instance user task in BPMN

2 Likes

Hi @pradeep.poojari,

Thanks for posting this. I forgot to add my solution after I figured it out :slight_smile:

Have a lovely day

1 Like

Thanks for posting the solution @pradeep.poojari