Chrono Forms v5 Unique ID

ltempest 06 Mar, 2014
Hello,
I have found this:

http://greyhead.net/how-to-docs/cfv4-unique-id-gh-action

Which shows how to set a custom unique ID with each Form Submission.

How do I setup a 'hidden' field in v5 so that each submission is given a unique ID that is sent in the email and can be referenced?

Thanks

Lee
GreyHead 07 Mar, 2014
Hi Lee,

There's a Hidden Field element in the Designer tab.

Personally though I wouldn't set a unique ID until after the form is submitted.

Bob
ltempest 15 Mar, 2014
Bob,
Thanks for the reply, How do you recommend I set a field once the form is submitted? Can this be done in the actions? if so how?

Thanks for the help.
GreyHead 15 Mar, 2014
Hi Lee,

Add a Custom Code action with code like this:
<?php
$form->data['some_name'] = 'some_value';
?>

Bob
ltempest 15 Mar, 2014
Bob,
Thanks for the reply, I think I understand your code and can add this to the submit actions.

However, and my apologies, I need the unique ID to increment on every submission.

Thanks

Lee
GreyHead 16 Mar, 2014
Hi Lee,

The simplest way is to save the data in a database table and use the record id.

Bob
ltempest 18 Mar, 2014
Bob,
My client is quite particular about what he wants to come through on the email when a form is submitted. His question to me was:

Ideally, I'd like it to start from some random number (say 1126) and
increment by one digit with each new ID.
Also, if possible to prefix it with MRIT-ID_ would be good.

So the numbering would begin MRIT-ID_1126
MRIT-ID_1126
MRIT-ID_1127
MRIT-ID_1128
MRIT-ID_1129

Etc.



This then allows them to manage the submission through their own internal business process.

How can I add a 'hidden' field on the form save to db and email so that its includes this incremental numbering?

I think i need to dig out my credit card and buy you a beer if I can resolve this!

Thanks

Lee
GreyHead 18 Mar, 2014
Hi Lee,

I'd still do this after the form is submitted, you don't' need to assign it until then.

I'd save the record in the database and get back the record id (I'm not sure how to do this in CFv5 but add a debugger and I expect that it is there. The use a Custom Code action before the Email action to create the ID.(assuming that the record id is in $form->data['cf_id']:
<?php
$uid = $form->data['cf_id'] + 1126;
$uid = sprintf('%04d', $uid);
$uid = 'MRIT-ID_'.$uid;
$form->data['uid'] = $uid;
?>
Then use {uid} in the Email template.

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