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 Ryguy2
#822182
Hello,

I have a dynaform where 2 files could be uploaded depending on the conditions met in the form.
So File 1 and File 2 are not required
File 1 or File 2 could either be not uploaded or one of the other could be or both could be uploaded.
The uploads work fine.
Next step when you want the next user to view the uploaded document is where I am having a problem. I have a trigger setup to look for the files.
I added the @@file2_uploadpath thinking this would resolve my issue, but it doesn't. Is there a way to place and uploaded file into a link based on the variable it was uploaded as?

I have never tried to have 2 uploads in a case. I can't do this as a multiple upload as they pertain to different subject matter in the case.
Code: Select all
$caseId = @@APPLICATION;


$query = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND APP_DOC_TYPE='INPUT' AND APP_DOC_STATUS='ACTIVE'";

$result = executeQuery($query);

if (is_array($result) and count($result) > 0) 
{
  @@file1_uploadpath = 'https://"server"/sysworkflow/en/neoclassic/cases/cases_ShowDocument?a=' .   	$result[1]['APP_DOC_UID'];
  @@file2_uploadpath = 'https://"server"/sysworkflow/en/neoclassic/cases/cases_ShowDocument?a=' . $result[2]['APP_DOC_UID'];	
}
Thank you again for your help.
User avatar
By amosbatto
#822183
If you are using version 3.1 or later, you should use a Multiple File field, which automatically solves this problem for you by displaying links to files that were previously uploaded, so you can include the same Multiple File field in several Dynaforms.

If you are using File fields, then a trigger to create links to the uploaded files is the only option.
You can use the APP_DOCUMENT.APP_DOC_FIELDNAME field in the database to find the file uploaded to your "File 1" and "File 2" fields.

Here would be your trigger:
Code: Select all
$caseId = @@APPLICATION;
$file1Name = "File_1"; //set to the Name of File 1 field
$file2Name = "File_2"; //set to the Name of File 2 field
  
$query1 = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND 
    APP_DOC_TYPE='INPUT' AND APP_DOC_STATUS='ACTIVE' AND APP_DOC_FIELDNAME='$file1Name'";
$query2 = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND 
    APP_DOC_TYPE='INPUT' AND APP_DOC_STATUS='ACTIVE' AND APP_DOC_FIELDNAME='$file2Name'";

$result1 = executeQuery($query1); 
$result2 = executeQuery($query2); 

if (!empty($result1)) {
  @@file1_uploadpath = 'https://"server"/sysworkflow/en/neoclassic/cases/cases_ShowDocument?a=' . 
      $result[1]['APP_DOC_UID'];
}
if (!empty($result2)) {
  @@file2_uploadpath = 'https://"server"/sysworkflow/en/neoclassic/cases/cases_ShowDocument?a=' . 
      $result[1]['APP_DOC_UID'];	
}

Web3 development encompasses creating decentralize[…]

The Upland Clone Script, offered by Dappsfirm, rep[…]

Dappsfirm offers a bet365 clone script that mirror[…]

🚀 Tauchen Sie mit Immediate Alora AI in die Welt d[…]