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.

Random Number

  1. Unfortunately, I am unable to see support forums (even though this question has been asked).

    For each person filling out a contact form, we need a number generated and then included in the autoresponder message to them and to us. (form to be used for RMA# generation)

    So we need it start at let's say 000111 and then +1 for each new submission.

    Is this doable with Gravity forms and what skill level is required to get this setup?

    Posted 12 years ago on Sunday March 4, 2012 | Permalink
  2. Hi, bt-chadski,

    Each form submission creates an entry and those entries have a unique id when stored in the database. If you do not need a specific format for the number, I would recommend using this unique id. You are able to add this as a merge tag in the email notifications that are sent out. You can add additional text to the number. This number will be unique across all of your forms.

    Let me know if you still have questions.

    Posted 12 years ago on Monday March 12, 2012 | Permalink
  3. Hi Dana,
    This is great to know. Thank you. I have only 1 follow up question -

    Is there a way to make this RMA number start at let's say 000123?
    (otherwise I understand it will start 'counting' submissions')

    Posted 12 years ago on Monday March 12, 2012 | Permalink
  4. Well, to start your entries at a specific number, if you are comfortable with database table manipulation/queries, you could set the number that the auto increment field starts with. If you aren't really comfortable modifying the database, you could always submit a form until your entry id reaches the number you want your live form to start with (not the greatest way).

    I was trying to give you the easiest way to do it. There is another way, which would require a little bit of php code. If the number can be completely random, you can add a little bit of code to your form to populate a hidden field. The hidden field can then be sent in your email notification. This would involve adding the hidden field, checking the setting "Allow field to be populated dynamically" and adding a "Parameter name" in the input box that appears. Then you would add a Gravity Forms hook to your theme's functions.php file which would generate a random number which populates the hidden field. Then in the admin, you would select this hidden field as one of the fields which is sent in your email notification. Below is an example of the code you would add. This uses the hook "gform_field_value_$parameter_name (http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name).

    add_filter("gform_field_value_random_number", "generate_random_number");
    function generate_random_number($value){
       return mt_rand();
    }
    Posted 12 years ago on Tuesday March 13, 2012 | Permalink

This topic has been resolved and has been closed to new replies.