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

Moderator: amosbatto

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.

Is it possible to Integration between Processmaker & File server / FTP server?

The requirement is to find a way, after the case approved, the attachment can be saved automatically (in certain way / Protocol) to another server (normally FTP) for further operation / process.

Please confirm and suggest a better way to approach.

What version of ProcessMaker do you have?

In the final task of your process, you can a trigger like the following to save all the files from the current case to your FTP server:
Code: Select all
$ftpServer = '';
$ftpPath = '/var/www/pmFiles'; //set to the file path on the FTP server
$ftpUser = 'johnDoe';
$ftpPass = 'p4sSw0rD';

$caseId = @@APPLICATION;
$aFiles = executeQuery($sql);

//first add the directory with case number to the FTP server:
$connection = ssh2_connect($ftpServer, 22);  //set to the domain of the remote server
ssh2_auth_password($connection, $ftpUser, $ftpPass); 
$sftp = ssh2_sftp($connection);

//create directory for the case number on the FTP server:
$ftpCaseDir = $ftpPath .'/'. @@APP_NUMBER;
ssh2_sftp_mkdir($sftp, $ftpCaseDir);

//lookup the files for the current case:
$caseId = @@APPLICATION;
$aFiles = executeQuery($sql);
$g = new G();

foreach ($aFiles as $aFile) {
    $filename = $aFile['APP_DOC_FILENAME'];

    if ($aFile['APP_DOC_TYPE'] != 'OUTPUT') {
        $ext = pathinfo($filename, PATHINFO_EXTENSION);
        $filePath = PATH_DOCUMENT . $g->getPathFromUID($caseId) .PATH_SEP. 
            $aFile['APP_DOC_UID'] .'_'. $aFile['DOC_VERSION'] .'.'. $ext;

        //check if the file already exists. If so, then add an incrementing number to the filename:
        $aDirList = ftp_nlist($connection, $ftpCaseDir);
        $ftpFilePath = $ftpCaseDir .'/'. $filename;
        $i = 1;

        while ( in_array($ftpFilePath, $aDirList) ) {
           $ftpFilePath =  $ftpCaseDir .'/'. $filename .'_'. $i .'.'. $ext; 

        ssh2_scp_send($connection, $filePath, $ftpFilePath);
    else {  //if Output Document file
        //code for output documents is similar but I don't have time right now
This code will work in PM 3.1 and later. I'll post code for output Docs later this week when I find the time.
You need to have the ftp and openssl extensions installed in PHP. How did you install PM? You can check from the command line on your PM server with the following command:
php -m
(In Windows you will have to first change to the directory where PHP is installed.)
In the list you should see "openssl" and "ftp". If you don't, then you need to install it. In Linux, it is just a matter of installing the package.
In Windows, you will probably need to edit your php.ini file to include it. See:
If its files are not included in your PHP installation, then you will need to manually download its files and add them to your PHP installation, then include them in the php.ini file.

Primero, tus comillas estan mal y olvidaste termin[…]

First of all, you are using JavaScript, not Java. […]

Stop submit from javacript

Do it this way: form = $("#637207031573dcea[…]

I can't find the database table where this informa[…]