Hi
We are migrating all process instances of a process definition by using the process definition migrate REST call. However, we would also like to update / edit / add / remove some variables of said instances.
We found the following POST body as a solution:
{
"toProcessDefinitionId": "process:2:id",
"activityMappings": [
{
"fromActivityId": "sid-1",
"toActivityId": "sid-2"
}
],
"processInstanceVariables":
{
"name" : "value"
}
}
Does anybody know a way if it is possible to conditionally edit these variables, to see which value they already have in a certain activity of a running process before we would change them with the migration?
This is so that new process definitions don’t have to take into account that some values could be different from a previous process definition.
I find almost no documentation about these migration REST calls and their response are pretty empty when succeeded.
Thanks in advance
Hi rubends,
org.flowable.engine.migration.ProcessInstanceMigrationDocumentConverter#convertFromJson
converts the json from the request to ProcessInstanceMigrationDocument
you can add any pre/post upgradeScripts to your migration doc.
example:
...
"preUpgradeScript": {
"language": "groovy",
"script": "1+1"
},
"postUpgradeScript": {
"language": "groovy",
"script": "2+2"
},
...
change variable type:
processMigrationService.createProcessInstanceMigrationBuilder().preUpgradeScript(new Script("groovy",
"import com.fasterxml.jackson.databind.ObjectMapper\n"
+ "import com.fasterxml.jackson.databind.node.ArrayNode\n"
+ "import org.flowable.engine.impl.context.Context\n"
+ "\n"
+ "List<String> list = execution.getVariable('listVariable')\n"
+ "\n"
+ "ObjectMapper mapper = Context.getProcessEngineConfiguration().getObjectMapper()\n"
+ "\n"
+ "ArrayNode jsonArray = mapper.createArrayNode()\n"
+ "list.each {jsonArray.add(it)}\n"
+ "\n"
+ "execution.setVariable(\"listVariable\", jsonArray)"))
.migrateToProcessDefinition(targetProcessDefinition.getId())
.migrate(processInstanceToMigrate.getId());
Regards
Martin