Add new rows to 2 related tables in one action

I have a simple CRM that uses the Glide Tables ‘Leads’ and ‘Notes’.

The New Lead form provides for the entry of the Lead Name, Phone and Email addresses. There is also a Choice item showing ‘hot’, ‘medium’ and ‘cool’.

I want to use one button to
a) Create a new Leads record;
b) Using the RowID of the new Leads record, create a new ‘Notes’ record that is related to the Leads table; and
c) I want to update the new Notes record with current date, Note text that is ‘New Record Created’, and the Category value.

Can this be done?

Thanks, Jack

I think in the on-submit action of your Leads form, add an add row action that writes to the Notes table with the info you need.

That does create the two entries. I should have figured that out - thank you very much.

However, it appears that I needed to create two additional columns in the Leads table and update one with the Row ID of ‘this item’ and the other with the Category so that they could be passed through to the Leads and Notes tables respectively.

What I was hoping was that I could just fire another ‘Show Form Screen’ like the Add button dues from Leads again and enter the next one. However, the Form Screen that pops up is for the Notes table.

Any ideas how I can get the original Form Screen to appear using a customized Action?

Thanks, Jack

That sounds like something is not set up correctly though. If you’re using a form for Leads, then you would already have access to the rowID of the Lead to pass through to the Notes table.

If by Category, you mean “hot”, “medium” or “cool” and you have already added it as a column to write to in the Leads table, you should also have access to it in the Add Row action.

You shouldn’t have to have a new form if I understand you right, just add an on-submit add row action to record the row to the Notes table.

To “enter the next one”, just open the Leads form again.

  1. Thank you. So, I did some more experimenting and can now see how to get the RowID. I was just attempting to use a text entry field (that obviously couldn’t work). Based on your comment, I just now tried a Fields component with the single RowID field shown, that solved that problem.

  2. Correct, except it is not destined to be saved in the Leads table as a rule. It is for the Notes table, so I put that field into Leads to accomplish that functionality. Thanks again.

  3. Just opening the Leads form again works, but I am trying to get the Custom Action to just go back to the Leads Entry so that the user is saved that step.

IDEALLY, I would like to be able to use the Data Grid as a part of a Data Entry form so that multiple fields could be copied into it at once. However, I can’t figure out a) how to get the Data Grid to reference a new row - it wants to use ‘This Item’ as the source which is one of the items that already exists in the table, not the new row; nor b) how to reopen a data entry form for an Action.

That way, they could copy a row of data from a spreadsheet just a mouse and Ctrl-C and Ctrl-V and click next (with the app updating the Leads and Notes tables immediately without any user intervention) and enter the user would just be able to enter the next row without letting go of the mouse. Short of allowing an import for the user, this seems like it would be the fastest way to enter new leads.

Your help is greatly appreciated. Thanks, Jack

Try a show form action just on the on-submit action of the Leads form. I don’t know if it leads you to a never-ending loop of forms, but please try it.

I don’t think that’s doable. You would still have to use a form tied to the title action.

Wow. Working on the weekend! Thanks.

  1. “Try a show form action just on the on-submit action of the Leads form.”

Thank you for the insight. That works and saves the new record, but when it goes to open the Add form again it creates a new version of the Add form that points to a different table. I can change that new version to be what I want and put the show the form action on it and that works, but again upon saving the record, it creates yet another new version of the Add form pointing to the same different table. For the fun of it, I took this 4 levels deep before giving up. So, now I can add 4 records (with 4 slightly different Add forms I have created) before it is not useful (pointing to the wrong table would be disconcerting to a user). I suppose I can have the 4th one just not do a show form.

I could have handled an endless loop by simply adding a ‘Done’ button to the form.

  1. “I don’t think that’s doable. You would still have to use a form tied to the title action.”

I don’t understand this. The title action is “Show Form Screen”. The Data Grid works wonderfully for editing/adding data for a record, it needs to point somewhere and if I point the ‘This Item’ it selects the first row in the Leads table. It has already created a new RowID at the end of the table, but I don’t know how to reference that.

I tried letting the Data Grid update the first and adding a ‘Set Column Values’ Action to the Submit button so when it is pressed, it would copy those updated values to my new row from ‘This Item’, but that didn’t work. The Data Grid did update the first row, however.

Is there a way to copy items from one row to another? I will have the RowID from which to copy or I can add a column and designate the source row.

Thanks for your help. - Jack

Yeah that was what I fear, so it did indeed create an endless loop.

I mean you can’t do what you wanted to here, there’s no native support for what you want. The only way you can add rows in a Data Grid component is by using that title action, and the title action can only be a show new form screen.

Thank you for your help. I have now spent the week looking for a work-around and have finally decided not to fight it. I was thinking I was just not creative enough to come up with some method, but I am willing now to accept that the method does not exist - today. Thanks again.

1 Like

Hi Thinh,

I figured out how to do it using the Data Grid.

I can’t pass the new record ID to the data grid, but I can use the Data Grid filter option to locate the newly created record. I create a time-based Locator value in the user’s record and also in the Add Row Action that creates the new record and in the filter look for a record that has the Locator value that is greater or equal to the one in the user’s record. I find that I can’t just use Current Data and Time because the compare function in the filter appears to compare only the date value ang ignores the time value.

Then, to add a new row, I created an action that referenced that page’s URL. The Action updates the value in the user’s Locator column and then calls the URL and I now have a blank rom in which to enter more data.

The only downside is that when I finally cancel out, I end up with an extra empty row in the table into which I am entering data.

The row-at-a-time pasting doesn’t generally work in the development mode (it did at least once, but I couldn’t replicate), but it does work in the published version. So, with one copy and paste, I can take a whole row in from an excel sheet.

In fact, while playing with it, I set up multiple blank rows and found that I could copy several rows in at once.

I’m not sure I fully understand this. Are you creating a new empty row everytime a button is clicked, and then allow users to “paste” into that row?

Correct – or even a set of rows. And each new entry is done on the same form. It clears and the user is forced back to the initial collection and press Add again.

FYI. I just thought you might like to know.

  • Jack
1 Like