PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Incremental Numbering In Hidden Field

  1. I searched around and saw a few old answers to a similar question, with talks of adding the feature. Not sure where things stand on it, or if a workaround has been created?

    What I would like to do is have a unique number / ID submitted to me when a user fills out a form. I saw something about entry id but no clue how to add this to a hidden field?

    So if possible, how would I pass something like

    c79#######
    where c79 stays constant, but the ####### are incremental?

    I am okay if they skip or worst case even random.
    Right now I have
    {date_mdy} - {referer} - {user_agent} - {ip}

    In my hidden field and it works perfectly. Can I also add c790{entry_id}? or is much more complex then that?

    Thank you!

    Posted 13 years ago on Monday December 19, 2011 | Permalink
  2. Do you need the number to be truly sequential?

    If so, then entry id won't be ideal because the entry id is sequential, but not per form... it's sequential across all your forms. Meaning entry id 1 and entry id 2 may be form form id 1, but entry id 3 might be for form id 2. Entries are stored in the same table so the id is sequential as far as all entries go.

    If it needs to be truly sequential and incremental then you would have to do this using custom PHP and dynamically populate the hidden field by first querying the existing entries and seeing what the last number was and then incrementing it.

    If you don't care that the numbers aren't truly sequential, but are incremental, then you could use the entry id. However, the entry id doesn't exist until the entry is created so you can't use the entry_id merge tag in the default value field of the hidden field because the entry id doesn't yet exist when that is processed.

    What you would have to do is use the gform_after_submission hook and dynamically populate the field with the entry_id from the entry object.

    So either way, to do what you want to do is going to require some custom PHP. Here is documentation for the gform_after_submission hook:

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    The gform_after_submission hook has access to the entry object which is documented here:

    http://www.gravityhelp.com/documentation/page/Entry_Object

    Posted 13 years ago on Monday December 19, 2011 | Permalink
  3. Thanks Carl,

    So the numbering part makes sense. Everything can be sequential regardless of the form. I currently have 2, and will probably have 3 total. So that is fine. It actually works better for my needs to have them sequential regardless of the form.

    Implementation, what you linked to seems a bit over my head, but it looks like it is built in and I did not notice?

    So to implement it, I do the following:
    Go to edit forms > notifications > then paste in: "CustomerID: C79000{entry_id}" where I want the number to show up in my email.

    And when I tested it it, it went from "CustomerID: C7900011" to "CustomerID: C7900012". So that seems like it is totally fine.

    When I get to 99 though it seems like it will break.

    CustomerID: C7900099
    CustomerID: C79000100 instead of:
    CustomerID: C7900100

    I would love to somehow be able to put {entry_id; ddddddd} in this, in order for the numbers to start at 0000001 vs 1.

    In my case though I think I can just do C79-X and it will go from there.

    In my emails it is appearing outside of the table format of the email, which is fine for my needs, but to make it within the table would require some of the "php tweaks" you mentioned?

    Thanks!

    Posted 13 years ago on Monday December 19, 2011 | Permalink
  4. It should not be appearing outside the table format of the email. Can you paste the source of an email at pastebin.com or pastie.org so we can see what's happening?

    Also, are you using the {all_fields} token or have you crafted a custom notification?

    Posted 13 years ago on Tuesday December 20, 2011 | Permalink