Say I have an API query to update a row, and I have a modal on one page that can update a row, but a form elsewhere that could also update the row, but both structures involve identically named elements such that the only difference between them is the parent widget, is there a way to generically reference “the widget that called us”.fieldwidget instead of having to write two queries, one for the form and one for the modal?
Also, when updating a row, I notice if the update row object is just {{modal.data}} it pulls all of the fields from the modal and if I have named them correctly, will update my sheet without me having to write out each one. However, if I just want to add another item to that, say
{{table.selectedRow.rowIndex}}, {{modal.data}} it doesn’t like this at all so as a workaround, I’m just including a hidden {{table.selectedRow.rowIndex}} on the modal, but that doesn’t seem like the “right” way of doing it.
Hi Eric,
You can pass the field values as parameters to your query. Check our documentation on how to run a query with parameters.
Here’s also a sample app that should help you understand the concept.
“This” is great, and solves either of the two problems I listed above, but I’m just missing the syntax to solve both of them.
So if my query uses {{this.params}} and my button has
{{
query.run({
modal.data
}}
this seems to work for passing all the fields in, but means I have to keep the hidden “rowindex” field on the modal. Or I can do:
{{
query.run({
table.triggeredRow.rowIndex
}}
and pass the row index, but then I’m missing all the fields from the modal. I’m sure I’m just missing the correct punctuation to put both modal.data and table.triggeredRow.rowIndex together.
To simplify this workflow, I think you could use a JSON Form widget instead of a normal Form widget and in the Modal, you could use a JSON Form too for your inputs. Then you can just send JSONForm1.formData and JSONForm2.formData as arguments to your query.
I assume you are triggering the query run when submitting the form. Then for each submit button, you run the query with the corresponding data. E.g., for JSONForm1: {{ query.run({ JSONForm1.formData}) }}
So there is no way to include multiple objects in a single run parameter?
If not I can find another way to do it. The JSONForm solves most of the issues, and having a hidden field in the form will solve other issues. I just assumed I was missing something obvious like sticking a semicolon or comma or brackets between them and it would work.
EDIT: on further review, JSONForm is nice but won’t actually work for this particular instance because I can’t control layout of the elements further than order or visible/nonvisible. Looks like I’m back to including a hidden rowIndex text widget inside my form.