This can be done by creating a trigger to generate an output document and firing the trigger after the dynaform on a specific condition.
In the dynaform, take the following web controls:
* a hidden field(named action)
* a submit type button(to generate the output document on its click)
* a link field(where you can download the output document)
Write the following javascript in the dynaform:
Code: Select allhidelink();
function hidelink(){
var action = $("#action").getValue();
if(action != "output" ){
$("#filelink").hide();
}
}
$("#opdoc").find("button").click(function(){
$("form").saveForm();
$("#action").setValue("output");
$("#filelink").show();
});
$("#submit0000000001").find("button").click(function(){
$("#action").setValue("");
});
Here, opdoc is the ID of the button which generates the output document.
Set the value of action to "output" for generating output and "" to submit the form.
Create a trigger with the following code:
Code: Select allif(@@action == "output"){
$outputid = "502792749586c9ae036e5e5086358080";
$case = @@APPLICATION;
PMFGenerateOutputDocument($outputid);
$query = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$case' AND DOC_UID='$outputid' AND APP_DOC_STATUS='ACTIVE'";
$result = executeQuery($query);
if (!is_array($result) or count($result) == 0) {
die("Error: Unable to find generated Output Document in database.");
}
$d = new AppDocument();
$aFile = $d->Load( $result[1]['APP_DOC_UID'] );
@@outDocUrl = 'http://' . $_SERVER['SERVER_NAME'] .
'/sys'. @@SYS_SYS . '/en/neoclassic/cases/cases_ShowOutputDocument?a=' .
$aFile['APP_DOC_UID'] . '&v='. $aFile['DOC_VERSION'] . '&ext=pdf';
@@outDocFilename = $aFile['APP_DOC_FILENAME'] .'_'. $aFile['DOC_VERSION'] .'.pdf';
PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', '952915093586c9ae036af54027049960');
}
This trigger generates an output document and stores the link for it in @@outDocUrl. It then redirects the flow back to the same dynaform.
Set this trigger to fire after the dynaform on the condition:
@@action == "output"
Hope this helps