Inserting a direct link to open/download an Input Document in a Dynaform.

One of the questions we at the Processmaker Support Team usually get either in the Forums or at the Bug Tracking site, is related to inserting a link to an uploaded document in a Dynaform, so further users down the process can click on this link in order to download/open the document right on their browsers, like this:

Link to Input Documents screenshot

The link right into a Dynaform, after being clicked on.

This is a very simple procedure which involves one trigger, two hidden fields, a JavaScript field with some JS code and finally a link field for the link itself.

First, we need to create this trigger:

$caseId = @@APPLICATION;
$result = executeQuery("SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId'");
@@myVar = $result;
$res = @@myVar;
@@myVar= $res[1]['APP_DOC_UID'];
@@text_hidden = "click here to download document";
$dir="http://".$_SERVER['HTTP_HOST']."/sys".SYS_SYS."/".SYS_LANG."/".SYS_SKIN."/cases/cases_ShowDocument?a=".@@myVar;
@@address_hidden = $dir;

This trigger has to be run before the Dynaform where we want the link inserted, is displayed to the user.

Now we need to create 2 hidden fields at the beginning of this Dynaform, called text_hidden and address_hidden, and a JavaScript field with whatever name you want to give it, with the following 2 lines of JS code on it:

getField("link").href = getField("address_hidden").value;
getField("link").innerHTML = getField("text_hidden").value;

…and finally, a link field where we’re going to insert the actual link to the uploaded Input Document, called link.

The neat thing about this, is that you can use this link for Input Documents uploaded either by use of an Input Document step in a task (using the standard Input Document form) or a File field inside a Dynaform.

About This Author

Customer & Partner Support Manager for Colosa Inc. and ProcessMaker.

  • Javier Delgado

    Hola!
    Ya probé lo señalado y funciona perfecto, pero cuando quiero incluir varios Link tengo problemas.
    cual sería la forma correcta de hacerlo, porfavor..
    Espero respuestas…

    • Hola Javier,

      Te comento que justamente un usuario en el Foro preguntó exactamente lo mismo, a lo cual otro usuario respondió con la solución. Así es nuestra comunidad.

      Gracias por tu interés en ProcessMaker.

  • Javier Delgado

    Hello!
    Already tried the above and works perfectly, but when I include several
    Links I have problems.
    which would be the right way, please ..
    I hope answers …

  • Armando

    Gracias compañeros por el dato.
    en este momento lo voy a probar y al rato les cuento como me fue.

  • Muchas gracias me salvaron la pega 🙂