Please enable JavaScript to view this site.

The manual for the JobRouter developer

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

Perform dialog function

Scroll Prev Top Next More

Dialog functions can be performed via the POST route /application/steps/:workflowId/dialogfunctions/:functionName. Thereby, the function name must be stated in the form of a parameter functionName. Another mandatory parameter is the workflow ID of the desired start step (workflowId). In the request body the call parameters of the function and all necessary form values can be found, e.g. if they are identified in the called form function via getDialogValue.

Please note: If you want to run the dialog function in a new start step that does not have a workflow ID yet, insert the value new instead of the workflow ID. Additionally, the process name, process version, and step number must be inserted in the request body (processName, processVersion, stepNo).

Reply

The reply is in JSON format and contains the return value of the dialog function, the workflow ID, the process ID (instance identification), and the process step ID.

{

 "dialogfunctions": {

         "returnValues": {

                 "usernameAccordingToCheckbox": "Jane Doe (jdoe)",

                 "__DialogFunctionClassSaveCalled__": true

         }

 },

 "meta": {

         "workflowId": "d6e48c7de99fd065ff741a6cb195dffb0000002458",

         "processId": "d6e48c7de99fd065ff741a6cb195dffb0000001575",

         "processStepId": "d6e48c7de99fd065ff741a6cb195dffb0000003315"

 }

}

IF the PHP API function save was called in the dialog function, the parameter __DialogFunctionClassSaveCalled__ will be returned with the value true.

Example: Performance of a function in an existing step

In the example process and depending on the checkbox in the dialog, the full name of the transferred user or only the user name is returned in the return parameter usernameAccordingToCheckbox.

guzzlehttp

// User has been authenticated already

 

// Define function parameters and form values (in case they are retrieved in the PHP function, e. g. with getDialogValue)

$input = [

    "functionParameters" => [

        ["name" => "fullname", "value" => 0],

    ],

    "dialog" => [

        "fields" => [

            ["name" => "userNameField", "value" => "jdoe"],

        ],

    ],

];

 

try {

 $response = $client->request('POST', $route, ['json' => $inputData]);

 echo "Status code: " . $response->getStatusCode() . PHP_EOL;

 $body = $response->getBody();

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

 

 foreach ($decodedBody['dialogfunctions']['returnValues'] as $name => $value) {

         // Output: "userAccordingToCheckbox => jdoe"

                    echo $name . " => " . $value . PHP_EOL;

 }

} catch (ClientException $e) {

    echo $e->getMessage() . PHP_EOL;

    exit;

} catch (Exception $e) {

    echo "Error: " . $e->getMessage() . PHP_EOL;

    exit;

}

 

// Finish user session

cURL

// User has been authenticated already

 

// Define function parameters and form values (in case they are retrieved in the PHP function, e. g. with getDialogValue)

$inputData = [

    "functionParameters" => [

        ["name" => "fullname", "value" => 1],

    ],

    "dialog" => [

        "fields" => [

            ["name" => "userNameField", "value" => "jdoe"],

        ],

    ],

];

 

$response = $client->post($route, $inputData, 200);

 

if (count($response)) {

 foreach ($response['dialogfunctions']['returnValues'] as $name => $value) {

         // Output: "userAccordingToCheckbox => Jane Doe (jdoe)"

         echo $name . " => " . $value . PHP_EOL;

 }

}

// Finish user session