start case in groovy

1
0
-1

Hi, I need to start a case of a process in groovy, Im not sure if I have to call an API or if there is another way of starting a case

regards
Mauro

3 answers

1
-1
-1
This one is the BEST answer!

This is what we do...

ProcessAPI processAPI = apiAccessor.getProcessAPI();

String processToStart = "the Process I want to Start";
String latestVersion = "1.0"; //make sure this is the right format for your numbers - we found 1.00 is not the same as 1.0
long processId;

processId = processAPI.getProcessDefinitionId(processToStart, latestVersion);

//Start the process with a Map of Data that will be used in the newly started process

Map<String, Serializable> processData1 = new HashMap<String, Serializable>();
processData1.put("mergedAssignmentData", mergedAssignmentData1.toString());
processData1.put("whoIsTheSender", initiatorUserName.toString());
processData1.put("additionalText", chosenStepAdditionalText.toString());
ProcessInstance processInstance1 = processAPI.startProcess(processId, processData1);

regards
Seán

PS: As this reply answers your question, please mark as resolved by ticking the tick mark on the left of this reply.

1
0
-1

I got a worked example for you, but just cant get the forum editor to display it as code :)

Anyone any idea how to make this work? The two "< >" buttons do a very half-hearted job on anything over a few lines in length.

Comments

Submitted by msevillano on Mon, 11/07/2016 - 21:33

look like its bugged.

Submitted by Sean McP on Thu, 11/10/2016 - 09:08

A Tip on displaying CODE/LOGS correctly in Posts:

Do not use the Supplied Buttons above, for some reason they refuse to work correctly, and despite bringing it to Bonitasofts attention, it's low priority.

To Show Code/Logs correctly use

< code >
your code/log
< /code >

removing the spaces to allow the showing of code/logs correctly as here:

your code/log

Thanks and regards
Seán

1
0
-1

In groovy you have an easy access to whole engineApi, and the processApi is probably what you need to use.

But there is also another option. In the script you can prepare data that will be used to start process and save it into some variable (for example a map or list of maps if you plan to start more than one instance). Then in 'call activity' or 'send message' task you can start that process.

Best regards,
bpms.help

Comments

Submitted by msevillano on Mon, 11/07/2016 - 21:35

im using this: apiAccessor.processAPI.startProcess(apiAccessor.processAPI.getProcessDefinitionId("Proceso Importacion", "1.1"), listMemberships[index].getUserId());
, both data are recived properly, processDefinitionId and userId, but still not working

Notifications