Skip to main content
Ryan Howard (Amazon) ha fatto una domanda in #Sales Cloud

Hello! 

 

I'm trying to design a new flow wherein we create a collection of records to be created, that require data from several other collections. I've got everything figured out up until the point of generating the new record from a series of other collections we've gathered earlier in the flow. 

 

Goal: Create X number of MCR records, with data populated from related records. 

 

Flow: Record Triggered - On Creation of MSR Object Record. 

 

  • Get Opportunity 
    • [Need OppID]
  • Get Opportunity Team Members (Store in Collection Variable "OppTeamMembers") 
    • [NeedUserID]
  • Get Opportunity Splits (Store in Collection Variable "OppSplits")
    • [Need Split %]
  • Get Users where ID is in list "OppTeamMembers"
    • [Need SlackID, Team, Division]
  • Get TeamCommission Records where Team in Collection Variable "TeamList' (Store in Collection Variable "CommRecordList")
    • [Need Rates for IC, Director, Sr. Director]

 

I've got all of these ^ working just fine. I'm at the point of needing to create the final collection, where each field for the final collection will be derived from one of each of the other collections. The number of MCR records will be derived from the number of OppTeam Members (So for every Team Member, we need 1 MCR record). 

 

MCR Fields: 

Opp = OppID

User = OppTeamMembers.User.Id

Team = OppTeamMembers.Team

Division = OppTeamMembers.Division

Split % = OppSplits.Split%

IC Rate = CommRecordList.IC_Rate

Director Rate = CommRecordList.Director_Rate

Sr. Director Rate = CommRecordList.Sr_Director_Rate

 

Total Number of MCR records created will depend on how many OppTeamMembers there are. We have 1 member figured out, but I'd like to make this dynamic for multiple/unknown numbers of members. 

 

I've thought about creating loops under each Get, adding the specific field from that collection to the final MCR record collection, however I can't figure out how to ensure that all items in each collection are associated with the correct MCR. 

3 risposte
  1. Michael Brown (Salesforce) Forum Ambassador
    2 mag 2023, 17:37

    This is a tricky one, but I think you could achieve this through loops. 

     

    You could loop through Opportunity Team Members since that is what dicatates how many MCR records there are. 

     

    As you're looping through the Opportunity Team Members, you should be able to get the following from each iteration:

    • Opportunity Id
    • User Id
    • Team
    • Division

    You'll then need to get their Split.  The easiest way would be to use a Get Records, but using a Get Records inside a loop is not recommended. It could be used here if your opportunity teams are small, but otherwise, you could start another loop inside your OpportunityTeam member loop that loops through all splits. You could have a decision check to see if the SplitMember's id is equal to the Opportunity Team Member Id. If so, you could then store the split of that record. 

     

    You would then need to find the user's commission record. Again, you could potentially use a get records if there is a small set of data here, but it's not generally recommended doing that within a loop, so you could have another nested loop fire after the Opportunity Split loop ends. You could follow the same logic where you have a decision check to see if the Commission User is equal to the iteration of the Opportunity Team Member, and if so, pull that commission information into a record variable via an assignment. 

     

    After the commission loop ends, you could add the record variable you're populating to a MCR collection, and then have the loop go on to the next Opportunity Team member. Finally, after the Opportunity. Team member loop is done, you could then create all the records stored in the MCR record collection variable. 

0/9000