In the Opportunity object there are two custom fields called 'start_date__c' and 'stop_date__c'

I have a requirement where I need to create a flow that executes when the the Opportunity stage is Closed Won (this will be an autolauched flow executed with process builder) and create N amount of Ocupation__c records (it has a lookup to the Opportunity object) based on the difference between 'start_date__c' and 'stop_date__c' in the parent opportunity object.

So for example if 'start_date__c' = 2021-01-20 and 'stop_date__c' = 2021-01-22 the difference will be of 2 so I need to create two Ocupation__c objects.

I flow builder I've created a new variable resource of type formula that looks like this:

enter image description here

this formula is returning a Number (wich is the one that tells me how many days is the difference between the two dates)

Then I need to execute the flow, get the parent Opportunity record, loop over this formula returning the number and create one Ocupation__c record until the number returned by the formula is equal to 0

This is the theory .... but in the flow builder I'm not being able to do it and I don't know how to achieve this.

Any help would be more than valuable. Many thanks

1 Answer 1


A couple of points:

  • You don't need a process builder.
  • You can build a record-triggered flow (after save) and loop in that flow.
  • Here is an example on my Youtube channel: https://youtu.be/Y9AA5ke-5cw
  • If you are available, I will run a free training session covering loops this Tuesday. Find out here (recording will be posted on the Youtube channel above): https://superpeer.com/utkan
  • 1
    I don't think the solution in your flow will work as he wants to iterate through a loop for 1 Opportunity record to create n Occupation records based on the number of days between two date fields on the opportunity. I've been trying to work out a solution but it is messy with the flow loop as we don't have a way of doing a simple for loop based on a parameter in flow.
    – Dave Humm
    Jan 25, 2021 at 21:19
  • Exactly .... the mess is in the Loop for creating the Occupation records. I will check out your videos but I don't think you understood my problem. Thanks anyways Jan 26, 2021 at 16:47
  • I can only speak to what I understood, Yes. But I think this is doable based on my understanding. Jan 26, 2021 at 20:18

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.