What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    API: What is the right process to get submission data

    Asked by ajuedu on August 09, 2016 at 08:02 PM

    I reviewed the API documentation and would like to know the right process to get submission data.

    Let's say that i would like to get submission data of a specific {form_id} and push it to a database.

    Can I rely on the answer number to never change and get the value based on the answer number? Related: What if a field is being moved up and down? Where is the number coming from? is this the input_id? What if an input is deleted and then recreated - i guess that the answer number will change?

    Is that safer to first get the questions iterate through and get the value of  "name" and type. Then if for example I need the answer value for "first_name" (the name given to the field in the form field properties), then get the question number from the questions JSON - for example "5", then get the answer "5" and look for the value? This way as long as the name of the field does not change on the form I can always get the correct value for first_name.

    Is there a better process to do that?

      Thanks

    myalo

  • Profile Image
    JotForm Support

    Answered by jonathan on August 09, 2016 at 10:04 PM

    Please refer also to the API documentation about the submission_id.

    http://api.jotform.com/docs/#submission-id

     

    The submission_id is unique and determine a single submission only. 

    If I understand correctly, what you wanted to do is to capture the specific submission data. So using the submission_id will do this for you.

    Hope this help. Let us know how we can be of further assistance.

     

  • Profile Image

    Answered by ajuedu on August 10, 2016 at 01:38 AM

    It is not about how to get a submission data. This I understand can be done in multiple ways - /submission /submissions and so on.

    My question was about what the right process to get the value of input fields once I have got the "content" of submission. The "answers" are numbered. How do i know what field (question) a particular answer is for. 

    Here is a sample from the JSON i got

    "11":{"type":"control_textbox","text":"Anticipated Start Semester \/ Year","answer":"2018 Fall"}
    it does not say what is the name of the input field.
    Please read all the question in my post.
    Thanks

  • Profile Image
    JotForm Support

    Answered by EltonCris on August 10, 2016 at 03:31 AM

    Can I rely on the answer number to never change and get the value based on the answer number Related: What if a field is being moved up and down? 

    -> Moving the fields position will not change its field ID. It will never ever change unless you deleted the field and created a new one. 

    Is this the input_id?

    -> Yes, that's right. It is the number after the underscore on input id, e.g. input_3

    What if an input is deleted and then recreated - I guess that the answer number will change?

    -> Yes, the number will change. So when you delete a field and created it, make sure to update your script with the right field ID number.

    ---

    Additional info: Ways to find the field ID numbers easily.

    1. You can easily find the ID number under the field properties > advanced tab > then click the field details button.

    You can also find it in your form source code.

    2. Another easy way to get all your field IDs is to inspect your form using this API URL http://api.jotform.com/docs/#form-id-questions

    Example:

    Hope this helps!

  • Profile Image

    Answered by ajuedu on August 10, 2016 at 12:37 PM

    Thank you for a more complete answer. 

    For others who might be following this thread:

    What is the right process to integrate jotForm with your own system / database.

    I can see three different ways:

    1) Get the source code. Create a page on your website with the source code and change the action attribute of the form to call your server page which can process the data entered. The plus - easy full control on the look and feel and saving to your database. The minus - every time someone (assuming that the creation of the forms on jotForms are done by users and not developers) changes the form, the code needs to be copied over and the action attribute changed again. The developer will need to adjust the server code to address changes.

    2) Webhooks. The plus - probably simpler than API. You create the server page on your site and accept http posts and take the data and save it to your database. The minus - if the server page is down for any reason, submissions might get lost. I was not able to get a definite answer from jotForm, how many times or for how long will their server try to reach the webhook URL. As far as changes to forms, still whenever the form changes (new or changed fields) the developer who is responsible for your server code need to be notified.

    3)API. Running a schedules process on your system to query jotForm data, analyze it and save it to your database. The plus - if you make a mistake or the process is down, the data is always there and you can get it. As for getting only new data, it can be controlled by date and either the new flag or even using the unique submission id. If it is not in your database - it is new. If it is, and you allow for changing submission then it is an update. The minus - it is a little more complicated to implement the first time and maintain changes. As for changes in forms, still the same issue. Whenever a form changes the developer needs to be informed and the schedule process needs to be modified.

    To the issue of maintenance of the server code in all 3 options: There need to be a mapping between form fields and database fields. This mapping needs to be updated whenever there are changes in the form itself or whenever there is a change in requirements what data should be saved. The mapping can be as simple as an XML file that can be read by the server processes of even a database driven mapping with an interface where users can make changes to it and the processes can be more generic.

    I would appreciate if anyone who has faced these issues and did a customize integration with jotForm can comment or share their opinion

    Thanks

    myalo 

     

  • Profile Image
    JotForm Support

    Answered by Kevin_G on August 10, 2016 at 01:38 PM

    With the first method, getting the source code, it will be a bit hard to make changes on your form, for example, if you change a question then you need to re-embed the form to get the updated changes and also update your script, so you will be working basically twice. 

    Using Webhooks the process will work only once, I mean, your custom code will be triggered only when the form is submitted so there is not a way to keep running the code in order to get the updated data, only when there is another submission.

    The good way to achieve this will be via the API as you will be a very customized process, for example, if there is some problem with the server you can queue the new records and then attempt to insert them to your database later on. 

    Here are some links that I've found regarding this, I think they may help you: 

    http://stackoverflow.com/questions/7163313/how-do-i-queue-inserts-to-create-a-bulk-insert 

    http://www.phpjobscheduler.co.uk/ 

    So if you can set an specific time frame to insert all the records at the same time, instead of adding each record as it comes. 

    Hope this helps. 

  • Profile Image
    JotForm Support

    Answered by Kevin_G on August 10, 2016 at 01:39 PM

    You may also contact to our API team to get further assistance, here is the email: api@jotform.com