I'm creating a flow that creates two records on two separate objects. The objects are linked in a master-details relationship. But I cannot figure out how to create the relationship between the two while creating the records in the screen page, or at the createRecord level

  • 1
    You need to insert the master first before constructing the parent field on the detail record (once the master record is inserted, its ID is implicitly available to the flow) – cropredy Jun 6 '19 at 16:38
  • I guess I'm too much of a rookie to understand how to insert it. I tried a getRecord, but I don't think it's what I want to be using. And unless I'm wrong, there isn't a way to manually insert the Id into the new record without it being created yet... – Dan Watkoski Jun 6 '19 at 18:45
  • There are two different ways to insert a record and the approach is slightly different but neither approach requires a query / get record. See the answer below for one version. In the other version you map the created record id to a variable in the insert element. – gorav Jun 7 '19 at 0:02

Here's a simple example (Account w/ Contact) - although not master-detail but same principles apply

enter image description here

and each component is constructed (as seen by debug output) as:

enter image description here

the key point is that when you insert an SObject ("Create records"), the Id field of the inserted record(s) is placed into the record variable(s) and you can reference that variable later in the flow to set the parent Id of the child record (in my example, the Contact)

{!contact.AccountId} is set to the value of {!account.Id} in the Init Contact flow element.

SFDC actually tells you this in the dialog for Create Record:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.