Forums

[Help] Simple Workflow

googleg 22 Dec, 2009
Hi all,
I want to implement a very simple workflow process and I thought ChronoEngine could be the solution.

Here is basically the process I'm trying to implement:

1. A requester fills in a form. One of the fields being the email address of the approving person
2. An email is send to the approving person, asking to click on a link and later on approve or not the request
3. The link opens a window showing the request, and the approver can approve or reject it


Here is so far what I managed to do...

A. I have one form with all the info I need + a hidden input containing a "secret" random number
B. On submit, the email is going to the approving person, with the "secret" to be used as a key to approve the request
C. I have designed a second form, identical to the first one, that will show the information entered by the requester (using the "Profile Page" plugin to automatically fill in the values). The approving person is asked to enter the "secret" code to approve the request(*)

My problem is: I cannot figure out how to generate a link in my email to be sent to the approver. The link should be something like /index.php?option=com_chronocontact&chronoformname=display_form&id=<cf_id of the request being submitted right now> ...

How can I capture the cf_id before the email is sent, so that I can generate the link to be put in that email ?


Or am I going in a wrong direction ?

Thanks a lot for your help.



(*) This secret code is just to avoid the requester to self-approve his request by guessing the URL. Of course as it is now it can be viewed in the source of the form, so if I find a good solution to capture the cf_id before the email is sent I could probably find a better solution by generating the secret code at the very same moment and include it in the email instead of using a hidden field.
GreyHead 22 Dec, 2009
Hi googleg,

Switch the AutoGenerated code to run 'Before Email' then you can pick up the cf_id of the newly saved record. ChronoForms saves all the info saved to the db into $MyForm->tablerow["jos_chronoforms_form_name"]

There has been a recent thread exactly on this.

You can do all of this with one form if you want to. Instead of adding the cf_id to the url in the email add a random string; add the same form name and &task=extra.

Then add the code to handle the response into the ExtraCode box on the form. Basically you grab the random string from the url look it up and change the db record accordingly.

I did a client project very similar to this a month or so ago and it worked well. The basic idea is the same as the Joomla registration validation.

Bob
googleg 22 Dec, 2009
Thank you very much, it works like a charm.

I'm now generating dynamic URL in the email sent to the approving person, and the "secret code" is computed on the fly through a server side validation script on submit (no more stored in an hidden field, much better).


Now I'm hitting an other wall ...


You just mentioned that I could do with one form by playing with the extra code box. Here is what I'm trying to do: when the approving person clicks on the link, it shows the exact same form, of course with the information as entered by the requester (I'm using the Profile Page plugin for that) PLUS a text field to enter the "secret" code needed to approve the request.

So in the extra code I've done a copy/paste from the original form code, added an extra text field and I'm calling the form with the parameters "&task=extra&id=<cf_id>". Unfortunately this shows my form but all fields are empty. It's like if the Profile Page plugin was not acting any more to populate the fields.

Any idea ?
GreyHead 22 Dec, 2009
Hi googleg,

If you want to redisplay the same form then you don't need the task=extra option. Just add the necessary php at the beginning of the form html to check that the URL code is valid, pull up the current values and display the values plus the 'secret' code box.

I was taking a slightly different approach so that the url (or urls) in the email were sufficient to do the confirmation (or non-confirmation) without requiring any extra action by the user. (On the grounds that any action by a user stands an x% change of not ahppening or of going wrong).

With that approach you'd add &task=extra&code=some_random_string in the URL in the email. When a ChronoForm is called by a URL with task=extra then the code in the Extra box is executed *instead* of the form html.

Bob
googleg 22 Dec, 2009
Thanks again, I've managed to have everything working (well, I still need to customize the title of the mails depending on the context, but I'm sure the solution is already somewhere in the forum).

It's simply AMAZING how powerful Chorno Engine is ! In a few hours, without knowing anything about Joomla I could implement my simple workflow... Well done !


Now... I just a little technical problem.


As I said and to make things simple my form is first submitted by a person, and then a second person reopens the form, add some extra info to it and submits it again.

The problem is: the second time the form is submitted, it creates a new entry in the DB instead of updating the record.

I'll try to look into the forum, it looks so stupid I'm quite sure it's a FAQ !!

Thanks for your help, and congrats for the good job.
GreyHead 22 Dec, 2009
Hi googleg,

You need to make sure that the primary key field has a value in the $_POST array before the form is saved. If the value already exists the record will be updated.

Or in your case you could choose to code the update manually.

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger