Jotform API: The Autoincrement value does not increase when the form is submitted via Jotform API

  • guitricolor2
    Perguntado em 17 de agosto de 2023 às 13:07

    Olá, tenho um formulario que contem um campo com um autoincremento, quando realizo o envio do formulario através da API o autoincremento deste campo não é atualizado, sendo assim o campo está contendo informações duplicadas enviadas pela API ou diretamente via url do formulario.

    Como eu posso corrigir isso?

  • Jovanne Jotform Support
    Respondido em 17 de agosto de 2023 às 15:36

    Hi guitricolor2,

    Thanks for reaching out to Jotform Support. Unfortunately, our Portuguese Support agents are busy helping other Jotform users at the moment. I'll try to help you in English using Google Translate, but you can reply in whichever language you feel comfortable using. Or, if you'd rather have support in Portuguese, let us know and we can have them do that. But, keep in mind that you'd have to wait until they're available again.

    Now, let me help you with your question. Can you please try using the Unique ID widget which increments if there is a new submission on the form? Let me show you how to add it:

    • Click the Add an Element on the left sidebar.
    • Click the Widgets tab and search for the Unique ID widget.

    Jotform API: The Autoincrement value does not increase when the form is submitted via Jotform API Image 1 Screenshot 20


    Give it a try and reach out again if you have any other questions.

  • Guilherme
    Respondido em 5 de setembro de 2023 às 14:46

    Olá. muito obrigado pela resposta. Vou explicar melhor um pouco o meu cenario atual.

    Tenho um formulario que contem um campo com autoincremento


    "29": {

          "currentIndex": "6746",

          "hidden": "No",

          "idPadding": "0",

          "idPrefix": "CP",

          "labelAlign": "Auto",

          "name": "digiteUma",

          "order": "3",

          "qid": "29",

          "selectedField": "528c8b464b1a424916000004",

          "text": "Número do Pedido",

          "type": "control_autoincrement",

          "widgetType": "native"

        },

    Quanto realizo o envio do formulario atraves da URL, este campo de autoincremento funciona normalmente, porém como estou integrando o formulario em meu sistema, estou realizando as submissões atráves da API > POST /submission/{id}
    Quando eu realizo o envio atraves da API este campo de autoincremento não está atualizando

    Tentei utiliza as Opções da API para atualizar a pergunta ou até a propriedade mas sem sucesso, qual forma eu consigo atualiza este campo atráves da API?

    Exemplo(SEM SUCESSO):

    Update properties

    {

     "properties": {

      "currentIndex": "1234"

     }

    }

    Update question:
    {

     "questions": {

      "29": {

          "currentIndex": "1234"

      }

     }

    }

  • Jovanne Jotform Support
    Respondido em 5 de setembro de 2023 às 15:41

    Hi guitricolor2,

    May I ask if you have used a field for getting the value of your current index? Additionally, may I know the steps you made on how to implement such so we can further understand the process and see if we can recommend a much better way for you to implement such when using API?

    Once we hear back from you, we'll be able to help you with this.

  • Guilherme
    Respondido em 5 de setembro de 2023 às 17:27

    Jovanne, thank you very much for your response. I'll reply in English to make it easier to understand my question.

    I just need to know how I can update a field with auto-increment using your API documentation. It's straightforward:

    Let me explain my scenario once again.

    When I submit a form via the URL https://submit.jotform.com/XXXX, I have the following auto-increment field:

    (Data returned from the function: GET /form/{id}/questions)

    "29": {

    "currentIndex": "6746",

    "hidden": "No",

    "idPadding": "0",

    "idPrefix": "CP",

    "labelAlign": "Auto",

    "name": "digiteUma",

    "order": "3",

    "qid": "29",

    "selectedField": "528c8b464b1a424916000004",

    "text": "Número do Pedido",

    "type": "control_autoincrement",

    "widgetType": "native"

    },

    If I fill out and submit the form via the Jotform URL, this field performs auto-increment. However, if I perform a POST via the API, the field DOES NOT AUTO-INCREMENT.

    I just want to know how to update the value of this specific auto-increment field using the REST API because the API documentation available is very confusing and outdated.

  • Sweta Jotform Support
    Respondido em 6 de setembro de 2023 às 02:33

    Hi Guilherme,

    I tested the API to POST submissions and I am able to replicate it on my sample form. It doesn't increase the value automatically; However, on passing the value from the backend, it does reflect after submission. You can write a function in your backend code to generate a unique ID and then pass the generated value to the form with the question ID. Check out the sample here:

    submission[18][currentIndex]=1

    Jotform API: The Autoincrement value does not increase when the form is submitted via Jotform API Image 1 Screenshot 20

    Give it a try and let us know if you need any help.

  • Guilherme
    Respondido em 6 de setembro de 2023 às 09:50

    Hello Sweta, thank you very much for your response.

    The tip you provided I had already implemented in my backend to set a unique order number. This way, orders placed through my backend wouldn't have a chance of being duplicated. The issue arose when orders were made again using the Jotform page's form because on the form, this order number is a hidden field with auto-increment.

    If this post is helpful to someone, I managed to resolve it in the following way:

    Using the API PUT /form/{id}/questions (https://api.jotform.com/docs/#put-form-id-questions), when I place an order in the backend, I update the currentIndex field to the value of the current order. This way, when placing an order using the form directly on the Jotform site, it considers this new value for auto-increment.


    https://api.jotform.com/form/{formID}/questions?apiKey={apiKey}
    {
      "questions": {
        "29": {
        "currentIndex": "6800",
        "hidden": "No",
        "idPadding": "0",
        "idPrefix": "CP",
        "labelAlign": "Auto",
        "name": "digiteUma",
        "order": "5",
        "qid": "29",
        "text": "Número do Pedido",
        "type": "control_autoincrement",
        "widgetType": "native"
        }
      }
    }