¿How i obtain the processDefinitionid in order to start a proces using API REST?

1
0
-1

Hi everybody,

How i start a process , using a button in my personal page, in bonita documentation is there information about , how i start a case or how i obtain the case information, but i want to launch or start a process, when i press the button. i saw that for start a case for example i have to get the processDefinitionId, so how i obtain it , if the process still has not begun , really i'm very confused.

Regards.

Comments

Submitted by antoine.mottier on Mon, 08/10/2015 - 16:48

I want to make sure that I understand your question. Can you confirm that you want, from a page of your application, to allow user to start a new process instance?

To start this process instance you have two options:

  • Display to the user the instantiation form associated with the process definition.
  • Provide a form in the application page and add a button that perform the REST call to instantiate the process.

Which of the two option are you trying to use?

Submitted by claz08 on Mon, 08/10/2015 - 19:59

Hi Antoine, i want to Provide a form in the application page and add a button that perform the REST call to instantiate the process.

regards

2 answers

1
0
-1

Here is the REST API call to perform to get list of process definitions based on provided process name (replace "MyProcessName" with your actual process definition name): http://localhost:8080/bonita/API/bpm/process?s=MyProcessName&p=0&c=10&o=version&f=activationState=ENABLED

If you store the result in a variable (e.g. "processDefinitionArray") you can then define another variable initialized with a JavaScript expression that will build the URL to instantiate the process (we get latest element of the array to get the latest process definition version): return "../API/bpm/process/" +$data.processDefinitionArray[$data.processDefinitionArray.length-1].id + "/instantiation";

You can find such example in the Vacation Management example (I'm currently updating it to actually get the last version of process definition).

Hope this helps.

Comments

Submitted by claz08 on Wed, 08/12/2015 - 18:09

hi , currently i'm using php not AngularJS .In first place, this url , only retrieve me all the information about the process , through the "MyProcessName" , but now i need to launch the process when the user press the button . I think that if the process doesn't started yet , the processDefinitionId not will exist yet , therefore i will could not use it in my query .

regards

1
0
-1

Hi,

I think you're mixing up process and case. A case is an instance of a process.

To start a new case using the API, you need to tell Bonita which process definition should be instantiated. You need the process definition id. You can retrieve it using the REST API : documentation here

Then, when you start a new case of this process definition, the API will respond with a JSON representing the newly created case (documentation here).

Regards

Quentin

Comments

Submitted by claz08 on Mon, 08/10/2015 - 20:07

Hi , i know that the case is a simple instance of a process.I know how i obtain the case information from API RETS so my question is very clear , ¿How i obtain the processDefinitionid in order to start a proces using API REST?. i posted my idea in the the first comment . regards

Submitted by Quentin Choulet on Tue, 08/11/2015 - 09:41

Take a look at the process resource from the bpm API here. You can search a process by its name, displayName or version. You can also filter on name, version, deploymentDate, deployedBy, activationState with the value DISABLED or ENABLED, configurationState with the value UNRESOLVED, or RESOLVED, processId, displayName, lastUpdateDate, categoryId, label, supervisor_id.

So, when the user click the start button, you have to perform two calls to the API. The first one to retrieve the processDefinitionId, and the second one to create the case.

Here is a code sample using AngularJS $http service to perform the call :

$http.get('/API/bpm/process?p=0&c=1&s=' + processName)
.success(
      function (process){
        var processDefinitionId = process.id;
       
        $http.post('/API/bpm/case', {
            processDefinitionId: processDefinitionId
        }).success(
            function (createdCase){
                // do wathever you want with the case informations
            }
        ).error(
            function (error){
                console.log(error);
            }
        );
    }
).error(
    function (error){
        console.log(error);
    }
);

(Sorry for the bad indentation in the code sample, it looks like the comment editor doesn't care about leading spaces)

Submitted by claz08 on Wed, 08/12/2015 - 18:11

sorry , how i can to do this using PHP CURL, because i 'm not using Angular JS.

regards.

Submitted by Sean McP on Sun, 08/16/2015 - 10:35

You keep asking about PHP CURL.

This as such is not a supported language for BonitaSoft. The answer for what you have asked is above, but you have to translate this to PHP CURL, everyone else here uses JAVA etc...

Sorry about that

regards

Submitted by claz08 on Mon, 08/17/2015 - 20:21

Hi , my quetsion is.

have you pressed the execute button from bonita studio before to do this ?
because , what i want to do is create a button in my web page and then through it , i can start the process, is it possible to do this? or before, i have to press the execute button and then send my querys.

regards

Submitted by claz08 on Tue, 08/18/2015 - 14:34

the above comment is for Quentin Choulet .

Notifications