Update child records with new lookup (parent) record

Hello, I am completely new to Skuid and am enjoying myself so far, but need a little bit of help. I have a table of expense item records and want to allow the user to do the following: - select a number of rows and click ‘create new invoice’ button - complete a pop up to create a new client invoice record - update all of the selected expense items records (in the table) with the ID of the newly created client invoice record (in SF this is a lookup relationship) I have managed to get the first two items working, but am struggling to see how to update the selected rows with the newly created record. Any help greatly appreciated. Ben.

Action Framework Sequence to the rescue.   Here is a sketch. 

1. Add a “new invoice” model that creates a new row on page load.  We need this “proto invoice” to be availalbe when we actually go to assign it to expense report items.  (It should be above the Expense records model in your model list,  and should have the “Prevent Users from leaving page” property turned off (Model properties - advanced tab…) 

2. Add a Mass Action to the Expense records table.  It should run a multiple set of actions. 
-  Update field on rows:  The Invoice ID of the Expense records should take the ID of the New Invoice you created in step 1. 
- Open a popup: 

3. This popup should have the fields from the invoice record so you can add definition to the invoice. 

4. On the popup remove the save/cancel buttons from the field editor and add custom save and cancel buttons in a page title.   The save button should save both the Invoice and the Expense records models. 

What happens is that the new invoice model is created with a “Temporary Id”.  Step 2 applies that temporary ID to the selected expense records.  Then when you save.  The Invoice model gets saved first (this is why model order is important).  That save action replaces the temporary ID with a real salesforce ID,  which then replaces the Invoice ID on the expense records with the real one before saving that model to the database.

Hopefully this works.  

Rob, thank you very much for the reply. It is all very clear, but I am struggling with the Update field on rows at point 2 in your note. How do I get the Invoice ID onto the expense records? Do I leave the field to update and value blank? If not what should I put in them? Thank you! Ben

Yea - that could have been clearer. 

The trick is to use global merge syntax to populate the Invoice ID into the Value property of the action. 

The syntax would be something like this {{$Model.NewInvoice.data.0.Id}}

More information on merge syntax is available here: 

Great - thank you. That worked perfectly. Just saved about $1,000 of developer costs in 2 hours. Awesome.

Rob, is there anyway using the merge syntax to reference fields in the first selected record on a table. For the above problem to be solved perfectly I would pull a project id from the first selected expense item and pre populate the pop up for the invoice with the value. Cheers, Ben

Unfortunately - there is now way to use merge syntax to get the data from the first selected row.   The data is there,  you are just going to have to use javascript to get at it. 

Take a look at this tutorial to see more about creating custom actions for mass actions:  

A hint.  The javascript snippet can be called as one step of your action framework sequence.  Look in the community for JQuery Deferred Promise  strategies to ensure that the snippet is completed before next step in the action framework sequence starts.