Please enable JavaScript to view this site.

The manual for the JobRouter developer

Navigation: REST-API-Examples > Practical examples > Processes

Step actions

Scroll Prev Top Next More

If you want to send or store a specific step, use the PUT route /application/steps/:workflowId. For both actions the workflow ID of the step is specified as parameter workflowId. Further step actions are momentarily not implemented in the REST API. The desired action is specified in the HTTP request body of the request. Further parameter are process name, version, step number, and dialog type (Desktop  or mobile version). You can also specify values for dialog elements.

Please note: The step  should be locked by the authenticated user (see route PUT application/steps/<workflowId>/lock)!

The response is in JSON format and contains, among others, the process ID:

{

    "steps": [

        {

            "id": "354e2b74c003c9a45455075f64f374ac0000005445",

            "workflowId": "354e2b74c003c9a45455075f64f374ac0000005445",

            "processId": "354e2b74c003c9a45455075f64f374ac0000003809",

            "processName": "archiveDocument",

            "processVersion": 1,

            "stepNo": 10,

            "simulation": false,

            "newStep": 0,

            "dialog": "archiveDocument.1.input",

            "readOnly": 0,

            "action": "save"  // performed actions

        }

    ]

}

Example: Send an existing step

guzzlehttp

// User has been authenticated already

 

// A step lock was created for the user

 

// Define dialog data

$input = [

    'processName' => 'archiveDocument',

    'processVersion' => 1,

    'stepNo' => 10,

    'action' => 'send',

    'workflowId' => '354e2b74c003c9a45455075f64f374ac0000005445',

    'dialogType' => 'desktop',

    'dialog' => [

        'fields' => [

            [

                'name' => 'approvedBy',

                'value' => 'jdoe'

            ]

        ],

    ],

];

 

try {

 

    // Send steps with the defined data

    $response = $client->request(

        'PUT',

        'application/steps/' . $input['workflowId'],

        ['json' => $input]

    );

 

    // Process response

    if ($response->getStatusCode() === 200) {

        $body = $response->getBody();

        $decodedBody = json_decode($body->getContents(), true);

        $stepData = $decodedBody['steps'][0];

 

        echo "Workflow-ID: " . $stepData['workflowId'] . "\n";

        echo "Prozess-ID: " . $stepData['processId'] . "\n";

        echo "Dialog: " . $stepData['dialog'] . "\n";

    }

} catch (Exception $e) {

    echo "Error during performance: " . $e->getMessage() . "\n";

}

 

// Finish user session

cURL

// User has been authenticated already

 

// A step lock was created for the user

 

$inputData = [

    'processName' => 'archiveDocument',

    'processVersion' => 1,

    'stepNo' => 1,

    'action' => 'send',

    'workflowId' => '4c057f28ebc1740d5334bff12ddfe8870000000048',

    'dialogType' => 'desktop',

    'dialog' => [

        'fields' => [

            [

                'name' => 'approvedBy',

                'value' => 'jdoe',

            ]

        ],

    ],

];

 

curl_setopt(

    $curlHandle,

    CURLOPT_URL,

    'http://example.org/jobrouter/api/rest/v2/application/steps/4c057f2...'

);

curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'PUT');

curl_setopt($curlHandle, CURLOPT_POSTFIELDS, json_encode($inputData));

curl_setopt($curlHandle, CURLOPT_COOKIEFILE, 'path/to/cooke/file.cookie');

 

$response = curl_exec($curlHandle);

$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);

 

curl_close();

 

if ($statusCode == 200) {

    $stepData = json_decode($response, true);

    echo "Prozess-ID: " . $stepData['steps'][0]['processId'] . "\n";

} else {

    echo "Fehler beim Ausführen:  Code - " . $statusCode . ", ";

    echo "Response: " . var_export($response, true);

}

 

// Finish user session