Two separate updates from one form table and related issues

Table 1 is supported by a query (ShowAllReportRows) that contains a join of two tables (Report and Serpstack). I’d like to have two editable columns (viewrecord, pagetype) in the table. Viewrecord is in Report and pagetype is in Serpstack. The key to Report is “id” and “variation” and the key to Serpstack is a column named “serpstack” (the table and field names are the same). The ViewRecord column is updating properly and the ShowAllReportRows is refreshed.
I’m having trouble with the pagetype update. I originally had it set just like ViewRecord (Run query automatically when inputs change). First, I can’t get it to update. When I change the value, I see the query running, but it doesn’t update. Can anybody tell me what I need to change? Second, when I tell it to refresh the table it seems to go into an endless loop. Any tips on how to avoid that would be helpful. The third issue is how I can use the State values to help me fill in the filter by and changeset fields. Once I change a column, it briefly shows the recordUpdates values, but quickly gets processed before I can see the elements of recordUpdates. Is there a way to suspend the update so I can see the values to reference the appropriate value (e.g. table1.recordUpdates[0].serpstack)?


Hey @adrooney! Hopping in here to try to help :slight_smile:

First, you currently have id and variation for your filter by fields. Is there a reason you have both? Usually just the id is sufficient there :slight_smile: Unless your id column isn't unique. When you have an edit made and you run the update query, does it show you any particular error?

Second, when you trigger the ShowAllReportRows query on success of the update query, you mention there's an infinite loop. Is anything else triggering that Show query? Does that Show query have any attached event handlers?

Third, hmm the query should only be running when you manually trigger it from a "Save Changes" button or something. It looks like your update query is running automatically. Could you try changing it to only run manually? :slight_smile: Then you can manually trigger from a Save button event handler somewhere in your app.

Thanks for reaching out to me. The update for the column viewrecord is working correctly. I see why you questioned the two keys since id is typically the sole key to a table. In our case, id is for client id. The table has multiple clients. Within each client, the variation is the key. Therefore, I need both columns to represent the key.

With regard to the pagetype update (which is not working), I want the table to be updated each time the pagetype is changed. I do think that is likely the reason for the infinite loop. I do refresh the table after the update is complete. I did change the GUI mode trigger so the updates will accumulate in the recordUpdate buffer and not refresh the table. The strange thing is that, when I change the GUI mode trigger, it continues to launch the query after each change. It seems to ignore the change. That also means I can't check the value in the first position of recordUpdate by hovering over the script.

After I'm able to solve the update problem, I want to change the GUI mode trigger to execute with each change. The reason I want this option is because I don't want the user to make the change and then select an update button. I also don't want the updates to stack up and be done in batch. Lastly, I don't want a loss in power to cause a batch of changes to be lost.

I think the problem has to do with having two update queries for the same table. Even though I'm not changing anything in the viewrecord column, that query appears to be executing whenever I change the pagetype. Does that seem likely?

Hm just to double check, both of your queries are set to only manually run? I know you mentioned you want one to automatically run–is that the one stuck in a loop?

I'd be happy to take a look at your app if you're on Cloud (not self hosted)! If this sounds alright with you, the name of your app would be helpful :slight_smile:

That would be great! Cj@hipcraft.co and the app is Test for now.

Are you going to have time to look at this issue? Is there a way I can look at it at the same time?

Quick note! In your UpdatePageType query, you're passing in table1.recordUpdates.pagetype . This actually won't return anything since table1.recordUpdates is an array of objects, where each object represents an entire row that has at least one edited value.

You would just pass{{ table1.recordUpdates }} in the "Array of records to update" field.

Second, this error (also from UpdatePageType) seems to be indicating that the table1.recordUpdates property contains some columns (e.g. id) that

your Serpstack table does not contain.

This is likely because the table1.recordUpdates property comes from the table component data which comes from your ShowAllReportRows query which has columns like id.

Ideally, what would you like to be passing into your UpdatePageType query? Just the serpstack and pagetype columns? If so, you can do something like this:

I haven't tested running this query since I don't want to edit your data in case it's production data, but let me know if this works for you! :slight_smile:

Hey @adrooney! Sorry about the delay here, have been working through my inbox queue and just got to this one.

BTW, if you’d like to test it, you can change either value to “test” and I will happily go back and update it. Thanks for your help. I know you are very busy.

Using the code I shared above, your UpdatePageType query is working for me once I click the "Save Changes" button on the table! Is it working for you?

Thanks. Can you tell me how to do the viewrecord update in light of the bulk update for pagetype? Will both updates attempt to happen when the button is selected? If so, the two updates are on separate tables. Will it know to update the viewrecord only when it's changed and update the correct table? Conversely with the pagetype?

Based on your current setup, only the UpdatePageType query will run on click of the "Save changes" button, but you can certainly choose both if you need.

Update queries that rely on the recordUpdates property of a table will only update rows that have been modified in some way in the table.

Back to your original question, what part of this process is breaking for you? Let me know! :slight_smile: