cancel
Showing results for 
Search instead for 
Did you mean: 

REST Call Put method with request mapping

bhchemss
Star Contributor
Star Contributor

Hello everyone,

I want to update several variables existing in an array with REST Call

endpoint : api/runtime/process-instances/${id}/variables

Method : PUT

But in Activiti only we are allowed to update one variable because of the request mapping

I am using Alfresco Activiti

Please any help is appreciated

Kind regards.

1 ACCEPTED ANSWER

cjose
Elite Collaborator
Elite Collaborator

Btw, you can now do request body JSON mapping in the newer version of the product which was released last week. See REST call | Alfresco Documentation  for more details.

However as Greg said, a script/service task would be more appropriate in this particular use case.

View answer in original post

9 REPLIES 9

gdharley
Elite Collaborator
Elite Collaborator

not sure i understand your problem.

The API you cite allows you to update as many variables as you wish within the instance.

[
  {
    "name":"intProcVar"
    "type":"integer"
    "value":123
  },
  {
    "name":"anotherProcVar"
    "type":"string"
    "value":"myStrong"
  }
]

Cheers,

Greg

but I am using Alfreco Activiti environment , so how can I map this request as json body into the request mapping ?

gdharley
Elite Collaborator
Elite Collaborator

So you want to update a process variable in the current process instance and you want to use the REST connector?

Honestly, this is just dumb.

Use a script task/listener with the execution setVariable() call.

If you are afraid of scripting and Java, then Activiti is not the environment for you,

Greg

Your reply is kind of rude.

I just want to update variables of parent process with rest inside a call activity and not in same process, if you don't have an answer you can just not reply.thank you Smiley Happy

gdharley
Elite Collaborator
Elite Collaborator

Just trying to save you a lot of pain.

You cannot build a non trivial Activiti process solution without using Java and scripts, it was one of the basic premises of the platform from inception to take BPM to developers.

Apologies if you found my answer rude.

Greg

Apology accepted, thank you for your advice I will take it in consideration.

cjose
Elite Collaborator
Elite Collaborator

Hi Ben,

If you are trying to update/add a variable to a parent process from child via a groovy script, the following will do

runtimeService.setVariable( execution.getSuperExecutionId(), 'varname', 'varvalue');

-Ciju

bhchemss
Star Contributor
Star Contributor

Hi Joseph 

Thank you , this works like a charm

cjose
Elite Collaborator
Elite Collaborator

Btw, you can now do request body JSON mapping in the newer version of the product which was released last week. See REST call | Alfresco Documentation  for more details.

However as Greg said, a script/service task would be more appropriate in this particular use case.