I have used simple forms that triggered JS queries that ran API calls to insert or update records in a database. Pretty simple as on the JS Queries you can access the form objects directly {{ field_name.value }} reference. I am trying to do the same thing with a wizard. I have a wizard with multiple steps and at the end last step I added a button. The button initially triggered JS query but I soon found out that I could not access the fields within the wizard because of a scoping issue. Not sure how to get around that but I found a suggestion.
Basically in the first screenshot you can see the code behind the button. It has a simple script that triggers the JS Query. In the JS Query ideally I would like to add my JSON parameters and be able to submit the API call. This example does fire the API call but my parameter sent to the endpoint is NULL as you can see in the second screenshot. Do I need to do this in multiple steps? Or is there another way? My thought is if I could build the RAW JSON within the JS Query this would solve it but I cant see how to accomplish that.
I tried another way by adding the code to the button event handler. This does create the JSON for me. How can I pass this over to the JS Query? I tried using JSON and the RAW option. Note, I hardcoded the state value just as a test in this case but you can see where i passed the field value in.
Figured it out. My JSON parameter {{ additionalScope.company_name }} should have been {{ comp_name }}
1 Like