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.
#793156
Hi,

Is it possible to modify the properties of a multiplefile variable in order to link it to an input document?

The problem we experience is that files can be submitted by the user, but we don't want to be accessible in the "Documents" section as long as the project has not been approved and assigned to a specific number.

I also thought about creating two multiplefile variables, one linked to an input document and the other not, and manage to get a trigger to copy the files from one variable to the other.

Can someone help me with this?

Thanks!
#793160
Create two input documents. Give the first Input Document Process Permissions to block all users from seeing it and give the second Input Document Process Permissions for everyone to see it.

The multipleFile control should be associated with a variable which is associated with the first Input Document.
Then, add the following trigger to copy the files from the multipleFile variable to the second Input Document:
Code: Select all
//set to the unique ID of the second Input Document where the files will be copied
$inpDoc2Id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'; 

if (isset(@@approved) and @@approved == 'yes' and isset(@=specFiles1) and is_array(@=specFiles1)) {
   foreach (@=specFiles1 as $aFile) {
      //works in version 3.0.1.18 and later:
      PMFCopyDocumentCase($aFile['appDocUid'], $aFile['name'], @@APPLICATION, $inpDoc2Id);
   }
}

If the above code doesn't work, then you can also try the following trigger code to do the same thing:
Code: Select all
//set to the unique ID of the second Input Document where the files will be copied
$inpDoc2Id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'; 

if (isset(@@approved) and @@approved == 'yes' and isset(@=specFiles1) and is_array(@=specFiles1)) {
   require_once 'classes/model/AppDocument.php';
   $g = new G();
   foreach (@=specFiles1 as $aFile) {
      $extension = pathinfo($aFile['name'], PATHINFO_EXTENSION);
      $path = PATH_DOCUMENT. $g->getPathFromUID(@@APPLICATION) .PATH_SEP. 
         $aFile['appDocUid'] .'_'. $aFile['version'] .'.'. $extension;
      //works in version 3.0.1.18 and later:
      $newFileId = PMFAddInputDocument($inpDoc2Id, '', 1, 'INPUT', '', '', @@APPLICATION, @%INDEX, 
         @@TASK, @@USER_LOGGED, 'file', $path, $aFile['name']);
      //rename the filename of the copied file from its ID to the original filename:
      if (!empty($newFileId)) {
         $aProps = array(
            'APP_DOC_UID'  => $newFileId,
            'DOC_VERSION' => 1,
            'APP_DOC_FILENAME' => $aFile['name']
         );	
         $oDoc = new AppDocument();
         $oDoc->update($aProps);
      }   
   }
}
In this example, the variable @@approved is a dropdown box which has the options "yes" and "no". The first Input Document is associated with the multipleFile's variable @=specFiles1. The PMFAddInputDocument() function is used to copy all the files in the @=specFiles1 to the second Input Document. The trigger code then uses AppDocument::Update() to rename the file after copying to the second Input Document.

The 500 Internal Server Error is the general catch[…]

Really very nice blog information for this one and[…]

This is a long, lengthy and cumbersome process. T[…]

Great read for when on the road. The book provides[…]