save() and updateData() in one go

Is there any way I can get the latest changes from SFDC upon calling save(). Perhaps the data could come in the callback function as a parameter?

Rather than performing 2 callouts, save() then updateData(), I’d like to save a bit of time and do both in one go.

Please suggest what’s the most effective way of doing this.

Boris, depending on what data you are trying to retrieve with updateData(), you may not need to do updateData() at all — save() on Salesforce Models actually does a re-query on all top-level Model fields immediately upon successful save. That’s why fields like Formula Fields show up updated in the Model even without calling updateData(). Any fields updated as part of Triggers, Processes, or immediately-run Workflow Rule Field Updates should also appear immediately updated directly after a save() call without updateData().

That being said, save() will only do this immediate re-query on the Model rows that were actually changed. So there are still use cases where you will need to do an updateData() / re-query Models after save().

Here is a short summary of when you need to / do not need to do an updateData() after save():

When you need to do a Re-query Models / updateData() after Save Models / save():

- You want to see updated Child Relationship field values: save() does not re-query Child Relationships
- You want to see newly-created or updated records that were not modified / created as part of the save()
- You want records to appear re-ordered as per database changes: for instance, if you have changed the SortOrder on multiple OpportunityLineItems, and have ordered your Line Items Model by SortOrder, you will need to do an updateData() after save() in order for the records to be appropriately re-ordered.
- You want to see record changes to records matching Model criteria which you did not create/update/delete as part of the save() operation: save() only re-queries records that were created / modified as part of the save()
- You have slow-running Workflow Rule Field Updates: this one is difficult to be exact about, but we have seen occasionally that certain Workflow Field Updates do not “finish in time” for immediate re-queries to pick up on the changes. 

When you JUST need a Save Models / save() call:

- You want to see updates to any non-Child Relationship fields that were included in the Model being saved, for the records that were saved, including Formula Fields: for example, you change the Birthdates of several Contacts, and have an “Age__c” Formula Field also in the Model. No need to do an updateData() after save(), the Age__c field will be included in the re-query that Skuid does as part of the Model save()

Hope that helps!