Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.

In the processmaker web console, output documents are generate according to the language of the user logged in. i.e. create RTL pdf for the RTL languages and LTR PDF for LTR languages. But when generating output document by rest API, the documents are always generated with EN language. How can we generate an RTL output pdf document?

Create a separate Output Document for each language. If needing a RTL document, use this code in the HTML code for the template:
Code: Select all
<body dir="rtl">
This Output Document doesn't need to be assigned as a step in the process, but it can be. Then use REST to generate the Output Document file.

If needing an Output Document in multiple languages, while running cases inside the PM interface, there are two options. Either generate all the HTML content dynamically in a trigger based on the system language or create multiple output documents in different languages and use conditions to display only one of them based on the system language.

For example, the following trigger generates the HTML content dynamically in Spanish and English:
Code: Select all
if (@@SYS_LANG == 'es') {  
   @@fileContent = "<p><b>Nombre del Cliente:</b> "[email protected]@clientName."</p>\n".
       "<p><b>Dirección del Cliente:</b> "[email protected]@clientAddress."</p>\n";
else { 
   @@fileContent = "<p><b>Client Name:</b> "[email protected]@clientName."</p>\n".
       "<p><b>Client Address:</b> "[email protected]@clientAddress."</p>\n";
Set this trigger to fire before the Output Document step. Then, place @#fileContent in the Output Document template.

The other option is to create separate Output Documents for each language and then use the following condition for the step of the Spanish Output Document:
Code: Select all
@@SYS_LANG == 'es' 
Then use the following condition for the English Output Document step:
Code: Select all
@@SYS_LANG != 'es'
I haven't tried using an RTL language, but I imagine that you can do this. Create a trigger like this in your process:
Code: Select all
$docId = '954109698491477e1986b43042252891'; //set to the Output Document's unique ID
$_SESSION['SYS_LANG'] = 'he'; //set to your RTL language
$caseId = @@APPLICATION;
//find the generated Output Document in the wf_&<WORKSPACE>.APP_DOCUMENT table
   WHERE APP_UID = '$caseId' AND DOC_UID='$docId'";
$result = executeQuery($query);
if (is_array($result) and count($result) > 0) {
   $fileId = $result[1]['APP_DOC_UID'];
   $version = $result[1]['MAX_VERSION'];
   @@outDocUrl = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}/sys" . @@SYS_SYS .
   "/neoclassic/en/cases/cases_ShowOutputDocument?a=$fileId&v=$version&ext=pdf";  //change to =doc if Word Document
Then you can call PUT /cases/{app_uid}/execute-trigger/{tri_uid} to execute the trigger and GET /cases/{app_uid}/variables to get the value of the "outDocUrl" variable and then use that URL to download the generated Output Document file.

Everybody wants to be famous, but nobody wants to […]

Hi, I attached a sample config file, Please check […]

Error clicking on Participated

Hi, I attached a sample config file, Please check […]

Hello, Is it possible to set variables in a defau[…]