Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By cosyxu
#812780
Good afternoon,

I am using web-entry form for my process. I was wondering is there any way that I can prevent from duplicated posting?

For example, when I submit web-entry form, PM uses XXXPost.php file to post and start a process. If I stay at the successful page and press "F5", it will post again.

So is there any way that can allow only post once?

Thanks,
Yuan
User avatar
By amosbatto
#812786
The only way I can think to prevent this is add code to the end of the XXXPost.php file to immediately direct to another URL with the header() function which will display the information to the user. That way pressing F5 will not reload the XXXPost.php file. That means you will have to create a custom page in your processmaker/workflow/public_html directory to display the information. You can pass the information to display as GET or POST variables and use PHP to generate your custom page.
User avatar
By programerboy
#812791
Hi,

I think this is a bug in processmaker, because you can get action of web entry form for example XXXPost.php and call it several times without any post or get data.
Then you see that case number will increase.

Thanks
By cosyxu
#812794
amosbatto wrote:The only way I can think to prevent this is add code to the end of the XXXPost.php file to immediately direct to another URL with the header() function which will display the information to the user. That way pressing F5 will not reload the XXXPost.php file. That means you will have to create a custom page in your processmaker/workflow/public_html directory to display the information. You can pass the information to display as GET or POST variables and use PHP to generate your custom page.

Hi Amo,

I think that would be a good solution. Could you please provide more details regarding this solution? :shock:

Thanks in advance.
Yuan
By cosyxu
#812795
programerboy wrote:Hi,

I think this is a bug in processmaker, because you can get action of web entry form for example XXXPost.php and call it several times without any post or get data.
Then you see that case number will increase.

Thanks

Hi Programerboy,

Yes, the number will increase every time, so maybe we could use amo's solution to prevent this from happening.

Cheers,
Yuan
User avatar
By amosbatto
#812805
cosyxu wrote:I think that would be a good solution. Could you please provide more details regarding this solution? :shock:
Create the file workflow/engine/methods/messages/messages_NewCase.php with the following content:
Code: Select all
<?php
if (!isset($_SESSION['WEB_ENTRY_MESSAGE'])) {
    throw new Exception("Web entry message not defined.");
}
$aMessage = $_SESSION['WEB_ENTRY_MESSAGE'];
unset($_SESSION['WEB_ENTRY_MESSAGE']);

$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
G::RenderPage("publish", "blank");
In your shared/sites/{workspace}/public/{process-uid}/{step-uid}Post.php file, change the code from:
Code: Select all
    /**
    * By default show the case info, for the recently created case
    * you can change it or redirect to another page
    * i.e. G::header("Location: http://www.processmaker.com");
    /*----------------------------------********---------------------------------*/
    $G_PUBLISH = new Publisher();
    $G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
    G::RenderPage("publish", "blank"); 
To:
Code: Select all
    /**
    * By default show the case info, for the recently created case
    * you can change it or redirect to another page
    * i.e. G::header("Location: http://www.processmaker.com");
    */
    /*----------------------------------********---------------------------------*/
    $_SESSION['WEB_ENTRY_MESSAGE'] = $aMessage;
    $url = '../messages/messages_NewCase.php';
    G::header('location: '.$url);
    /*
    $G_PUBLISH = new Publisher();
    $G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
    G::RenderPage("publish", "blank");
    */
If you want to change it in all future web entries that you create, then also change the same code in workflow/engine/templates/processes/webentryPost.tpl.
By cosyxu
#812816
amosbatto wrote:
cosyxu wrote:I think that would be a good solution. Could you please provide more details regarding this solution? :shock:
Create the file workflow/engine/methods/messages/messages_NewCase.php with the following content:
Code: Select all
<?php
if (!isset($_SESSION['WEB_ENTRY_MESSAGE'])) {
    throw new Exception("Web entry message not defined.");
}
$aMessage = $_SESSION['WEB_ENTRY_MESSAGE'];
unset($_SESSION['WEB_ENTRY_MESSAGE']);

$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
G::RenderPage("publish", "blank");
 
In your shared/sites/{workspace}/public/{process-uid}/{step-uid}Post.php file, change the code from:
Code: Select all
    /**
    * By default show the case info, for the recently created case
    * you can change it or redirect to another page
    * i.e. G::header("Location: http://www.processmaker.com");
    /*----------------------------------********---------------------------------*/
    $G_PUBLISH = new Publisher();
    $G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
    G::RenderPage("publish", "blank");
To:
Code: Select all
    /**
    * By default show the case info, for the recently created case
    * you can change it or redirect to another page
    * i.e. G::header("Location: http://www.processmaker.com");
    */
    /*----------------------------------********---------------------------------*/
    $_SESSION['WEB_ENTRY_MESSAGE'] = $aMessage;
    $url = '../messages/messages_NewCase.php';
    G::header('location: '.$url);
    /*
    $G_PUBLISH = new Publisher();
    $G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage);
    G::RenderPage("publish", "blank");
    */ 
If you want to change it in all future web entries that you create, then also change the same code in workflow/engine/templates/processes/webentryPost.tpl.
Hi Amo,

Thank you very much for your detailed solution.

But the page was directed into the login page after I submitted. Does it because the url we used is under '../messages/messages_NewCase.php'?

should I put it into the public_html?

Thanks,
Yuan
By cosyxu
#812817
Hi Amo,

It seems the problem has been solved. I created a custom page under the public _html folder, and then updated the
Code: Select all
 $url 
with this page address.

Now after I submit a web-entry form, it will direct to this custom page.
Code: Select all
$_SESSION['WEB_ENTRY_MESSAGE'] = $aMessage;
    $url = 'http://localhost/customPage.php';
    G::header('location: '.$url);
I was wondering whether I could use this workaround for "Action by Email"? What I mean is that after a user click a "Y" / "N" in the email, it will show a ABE page says "Thank you for your response!", but currently Processmaker use one template for all the ABE action. Is it possible to customize a page for each of the process?

Thanks,
Yuan
By cosyxu
#812818
Hi Amo,

I was just thinking, when "webentryPost.tpl" generate new template, maybe I could change the code to this:
Code: Select all
$_SESSION['WEB_ENTRY_MESSAGE'] = $aMessage;
$url = 'http://localhost/{processUid}.php';
G::header('location: '.$url);
In this case, if I made some changes to the process, I don't need to go back to Post.php to update the URL every time any more as long as I put each processUid.php under the public_html folder as successful pages.

Regards,
Yuan
User avatar
By amosbatto
#812819
cosyxu wrote:I was wondering whether I could use this workaround for "Action by Email"? What I mean is that after a user click a "Y" / "N" in the email, it will show a ABE page says "Thank you for your response!", but currently Processmaker use one template for all the ABE action. Is it possible to customize a page for each of the process?
You can edit the source code of workflow/engine/methods/services/ActionsByEmailDataFormPost.php to redirect to different pages or create a different messages depending on the process. For example:
Code: Select all
$processId = null;
if (defined('PROCESS')) 
   $processId = PROCESS;
elseif (isset($_SESSION['PROCESS']))
   $processId = $_SESSION['PROCESS'];

if ($processId == '1234567890abcdef1234567890abcdef') {
   $aMessage['MESSAGE'] = 'Thank you for submitting information to Acme Industries.';
}
elseif ($processId == 'abcde1234567890abcdef1234567890') {
   $aMessage['MESSAGE'] = 'Thank you for submitting information to Coyote Traps.';
   $_SESSION['FEEDBACK_MESSAGE'] = $aMessage; 
   G::header("location: ../messages/mycustompage.php");
}
By cosyxu
#812821
amosbatto wrote:
cosyxu wrote:I was wondering whether I could use this workaround for "Action by Email"? What I mean is that after a user click a "Y" / "N" in the email, it will show a ABE page says "Thank you for your response!", but currently Processmaker use one template for all the ABE action. Is it possible to customize a page for each of the process?
You can edit the source code of workflow/engine/methods/services/ActionsByEmailDataFormPost.php to redirect to different pages or create a different messages depending on the process. For example:
Code: Select all
$processId = null;
if (defined('PROCESS')) 
   $processId = PROCESS;
elseif (isset($_SESSION['PROCESS']))
   $processId = $_SESSION['PROCESS'];

if ($processId == '1234567890abcdef1234567890abcdef') {
   $aMessage['MESSAGE'] = 'Thank you for submitting information to Acme Industries.';
}
elseif ($processId == 'abcde1234567890abcdef1234567890') {
   $aMessage['MESSAGE'] = 'Thank you for submitting information to Coyote Traps.';
   $_SESSION['FEEDBACK_MESSAGE'] = $aMessage; 
   G::header("location: ../messages/mycustompage.php");
} 

Thanks,
Amo

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[…]