- fillyabootsAsked on August 24, 2016 at 02:49 PM
Several of our forms are configured such that they have a reference field that is automatically generated (i think) on form generation, which is then written into the database on form submission. Is there any way of getting at what the next id value would be. For example, I am looking at the web api calls that are available, and there is one that gets the form questions:
In the response of this, I can see that one of the fields looks like this:"33": "currentIndex":"973", "explicitySetByUser":"Yes", "idPadding":"4", "idPrefix":"WB-", "name":"reference", "order":"3", "qid":"33", "text":"Reference", "type":"control_autoincrement" },
Is this saying that the last value to be written was '973', and should I submit a form now, the next value will probably be '974'.
I say 'probably' since I suspect that someone could submit at the same time and therefore get the same number. What would the database do in this situation (I appreciate that this would probably be quite unlikely)
- BenAnswered on August 24, 2016 at 03:17 PM
The index is actually incremented upon submission, so there is no way for it to have 2 of the same. Having that said, you do not need to pass your own value for the same field if you are trying to create a submission from your own server as this value is always created by JotForm servers - as mentioned above, during submission itself.
So even if you and someone else would submit the data in the same time, the actual Auto incrementation index is given while saving the data and only one can have the same ID.
Hope this helps, of course Al, do let us know if you have any additional questions :)
- fillyabootsAnswered on August 24, 2016 at 03:23 PM
Thanks for your response.
The crux of my problem is that I can see the correct reference being written into the table, but the value is blank in the email is generated. I was suspecting that the email was generated from the form submission rather than the data written into the table.
Anyway, was I correct in the way that I was interpreting the part of the json that I posted before?
- BenAnswered on August 24, 2016 at 04:11 PM
Actually Alex, no. That should be the index that you have last set your field to start from.
Since they you might have even got hundreds of submissions.
To get the last index, you would need to use the following API call:
The addition of limit parameter returns only the latest submission (so that you have a faster response time and less data to go through).
Hope this helps you.
Now in regards to the emails. I do suggest checking the email of your form to see if it is using correct reference to the unique ID field. It is possible that it is not, which is why it is sending you the blank value (or it is not set to be sent).
Do let us know how that goes and if you have any trouble finding the same, just let us know and we would be happy to look into the specific form and its emails to see what is the issue (we would need to know your form with the issue at that time).