Page 1 of 1

How to show error message to user without enabling debugger mode?

Posted: Mon Apr 15, 2019 5:34 am
by Zora99
I have a case where the user needs to upload a CSV file and save the record to the database, and they are often complaining about the record that is not saved to the database although they already upload the file. After I checked it through debugging mode, I found that their upload was not successful. Can I show the error message as a pop-up message to the user without enabling debugging mode?

Re: How to show error message to user without enabling debugger mode?

Posted: Tue Apr 16, 2019 12:15 am
by amosbatto
You can use a trigger like this:
Code: Select all
//set to the ID of the Dynaform where File is uploaded:
$dynaformId = '1234567890abcdef1234567890abcdef'; 

if (isset(@@__ERROR__)) {
    $err = @@__ERROR__;
    $g = new G();
    $g->SendMessageText($err, "ERROR");
    unset(@@__ERROR__); //clear error so it won't be detected the next time
    //if you want the case to return to the Dynaform where file failed in uploading:
    PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
} 

If you are checking the upload of a File field, then set this trigger to fire before the next step or before assignment if the Dynaform is the last step in the task. Do not set it to fire after the dynaform because at that point the file as not yet been saved in the database and placed in the server's file system.
See:
https://wiki.processmaker.com/3.0/Inter ... Text.28.29
https://wiki.processmaker.com/3.1/Proce ... Step.28.29

Re: How to show error message to user without enabling debugger mode?

Posted: Tue Apr 16, 2019 12:42 am
by Zora99
It works, thank you..

Re: How to show error message to user without enabling debugger mode?

Posted: Tue Apr 16, 2019 8:45 pm
by amosbatto
I added this example to the pmusers wiki:
https://www.pmusers.com/index.php/Displ ... oad_failed