How can I update the form calculation widget with the API?

  • Profile Image
    lengtche
    Asked on March 03, 2015 at 08:04 AM

    We're using the form calculation widget and it works great once all set up. Our problem is that we have so many products that it becomes quite the error prone chore to ensure we properly created our totals formula before sending off the calculated number to PayPal for processing. I know how to use use the API to update common form properties, but updating the calculation equation isn't actually going through.

    I can see the following JSON being returned when I issue a GET for my form properties - 

     "calculations": [ { "decimalPlaces": "1", "equation": "[{3}{4}]", "ignoreHiddenFields": "", "insertAsText": "", "newCalculationType": "1", "operands": "3,4", "readOnly": "", "resultField": "6", "showBeforeInput": "", "showEmptyDecimals": "" } ]

    Now say I want to update the decimal places of my calculations, I would issue a PUT to /forms/{id}/properties with the following data - 

    {"properties":{"calculations": [{"decimalPlaces": "4"}]}}

    This returns - 

    { "responseCode": 200, "message": "success", "content": { "calculations": [ { "decimalPlaces": "4" } ], "formID": "50607523092248" }, "limit-left": 9987, "duration": "26ms" }

    However, the decimal places never actually changed.

    How can I achieve this?

    Thank you.

     

  • Profile Image
    Ben
    Answered on March 03, 2015 at 10:11 AM

    I believe that you must issue the command to the questions since the above is changing the properties of the form, not of the fields, so this would be the correct link:

    PUT /form/{id}/questions

    I would however recommend taking a look at our developers forum instead since they would be able to explain this better there plus this is a forum for issues with our online JotForm Builder only.

    Thank you.