Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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.
By gregfly26
#795912
Hello,

I'm creating a new process to submit document to validate.

The idea is the first person who runs the process upload a PDF file as an input document in a file variable.

The second person (manager) will download file, sign with Adobe reader and upload the new file.
In this step, to be sure that the manager send the new one, I would compare size of both documents.

Is it possible to do this ?

Thanks in advance for your help.
User avatar
By amosbatto
#795931
I prepared a sample process to show you how to do this:
(30.69 KiB) Downloaded 241 times
Here is the trigger code that you can adapt for your process:
Code: Select all
//set to the ID of the Sign PDF DynaForm:
$signPdfFormId = '40954420159e830a7c244e0077508325'; 
$g = new G();
    
if (!isset(@=signedPdf) or !is_array(@=signedPdf)) {
    throw new Exception("No signedPdf variable or not array.");
}
if (!isset(@=originalPdf) or !is_array(@=originalPdf)) {
    throw new Exception("No originalPdf variable or not array.");
}

if (count(@=signedPdf) != count(@=originalPdf)) {
    $g->SendMessageText("There needs to be the same number of signed PDFs as orginal PDFs", "WARNING");
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $signPdfFormId);
}

//check if any of the signed PDFs are the same file size as the original PDFs:

foreach (@=signedPdf as $aSigned) {
    $signedExt = pathinfo($aSigned['name'], PATHINFO_EXTENSION);
    $signedPath = PATH_DOCUMENT . $g->getPathFromUID(@@APPLICATION) . PATH_SEP .
        $aSigned['appDocUid'].'_'.$aSigned['version'].'.'.$signedExt;
    
    foreach(@=originalPdf as $aOriginal) {
        $originalExt = pathinfo($aOriginal['name'], PATHINFO_EXTENSION);
        $originalPath = PATH_DOCUMENT . $g->getPathFromUID(@@APPLICATION) . PATH_SEP .
            $aOriginal['appDocUid'].'_'.$aOriginal['version'].'.'.$originalExt;
        
        if (filesize($originalPath) == filesize($signedPath)) {
            $g->SendMessageText("File '{$aSigned['name']}' was not signed. Please sign it and upload it again.",
                                "WARNING"); 
            PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $signPdfFormId);
        }
    }
}
 
You can't fire this trigger immediately after the DynaForm where the signed PDFs are uploaded. Instead, you need to fire it before the next step (or before assignment if the last step in the task), because at that point the file(s) will have been saved in the server's file system and a record added to the database in the APP_DOCUMENT table.

@DANSOL Thank you !!!!!!! You saved me :)

🚀 Kann ein Krypto-Bot beim Handel und Investieren […]

WazirX is a leading cryptocurrency exchange in Ind[…]

Sending messages with WhatsApp

Wordle offers a refreshing challenge for word enth[…]