How to Call a Process from another Process

Inside the same instance

There are several way to call a process from another process

Using the normal call

_orchestration_execute_service(
    $ubiqube_id, // The ID of your customer
    $service_name, // The name of your service (a path from Process/.../SERVICE_NAME, without .xml or .php)
    $process_name, // The name of your process (a path from Process/.../PROCESS_NAME, without .xml or .php)
    $json_body = "{}" // The body of your service : will be the $context of the process called
)

Using the external ref call

_orchestration_execute_service_by_reference(
     $external_ref, // The external reference of your customer (depending of this last one, it could be it's ubiqubeID or something else)
     $service_reference, // The reference of the service you want to call (If you don't know what it is : The manager prefix (UBI, MSA, etc.) + "SID" + the service instance ID)
     $service_name, // The name of your service (a path from Process/.../SERVICE_NAME, without .xml or .php)
     $process_name, // The name of your process (a path from Process/.../PROCESS_NAME, without .xml or .php)
     $json_body = "{}" // The body of your service : will be the $context of the process called
)

From an other instance

The two methods above will clear the context for a simple reason : you don't give the original context ($context will be empty) so the process will think you want to clear it.

The way to solve this is to pass parameters to the called process

Using the external ref call with parameters

_orchestration_execute_service_by_reference_using_parameters(
    $external_ref,
    $service_reference,
    $service_name,
    $process_name,
    $json_body = "{}" // Whatever you want from the time it's an array converted into a string -> you can use json_encode() on any array you want. It will be the $parameters of the process called
)

It works exactly the same way than _orchestration_execute_service_by_reference, but thanks to it you will have an access to $parameters in the called process. This $parameters variable will work exactly as $context, but it won't be save in the instance and you will not loose $context as you could with the previous tools. More than that, you will have the same $context that you could find by using the process in it's instance.

Example

<?php

/**
* This file is necessary to include to use all the in-built libraries of /opt/fmc_repository/Reference/Common
*/
require_once '/opt/fmc_repository/Process/Reference/Common/common.php';

function list_args() {
}

logToFile(debug_dump($context, "******CONTEXT******"));

$external_ref = "UBIA7";
$service_reference = $context["SERVICEINSTANCEREFERENCE"];
$service_name = "Process/Reference/Tests/Test_external_ref_with_params";
$process_name = "Process/Reference/Tests/Process_Execute_With_Params";

_orchestration_execute_service_by_reference_using_parameters($external_ref, $service_reference, $service_name, $process_name, json_encode($context));

echo prepare_json_response(ENDED, "CALL SERVICE OK", $context, true);

?>