[SalesForce] How to get ids of records I created in visual flow

I have a flow where I've looked up and looped through service contracts and looked up and looped through contract line items storing sobject variables which I've placed into a collection. I then create opportunities with the info I have from service contracts.

I have 2 questions:

  1. I want to check if the way I'm getting the newly created oppty ids is the only way or if I'm missing something. I do a fast lookup on opptys looking for an id I save on the opptys as I create them. I then loop thru the collection and save the ids as sobject variables which I add to a collection.

  2. Is is possible to add a sobject variable to a collection and later in the flow add more data to the same sobject variable and then add that data to the same collection without overwriting the variables gathered?

In my case, I use the same collection to collect the newly created oppty ids and to which also had other sobject variables added but when I attempt to fast create the oppty line items it does not work, stating that info I verified with screens earlier is not present

Hope that makes sense!
Top half of the flow

Second half of the flow

Best Answer

Once you insert a sObject collection, you should be able to access the record IDs in the collection itself.

To demonstrate, add a screen element and display the sObject collection that you just inserted. You will see a list of opp IDs.

Screenshots below for a sample flow that creates two account sObject variables, adds them to a collection, and inserts the collection. You can see that prior to the insert, if you display the sObject collection, it just shows a commma. After the insert, you see the two IDs.

Flow

flow overview

sObject collection before insert

soc before insert

sObject collection after insert

soc after insert