You need to sign in to do that
Don't have an account?
Visual Workflow: Flow is not creating all the records
I have created a visual workflow to find the opty team members on a related opty (Previous Year Opty) and add them to the current opportunity being created. When I tested the flow, it only created 1 of 3 opty team records I assumed it would. When reviewing my debug logs, I see that it looped through all three, but only one created. Any help would be appreciated. My Flow is below. Any help is appreciated! Thank you!





Reason for your flow not working:
- Record Create element is used to create a single record and not multiple records in bulk.
- Your Record Create is not pointing back to Loop element. This means that your flow stops after the Record Create element
Flaw in your flow is that you are trying to create record within a loop, which is not a recommended approach as you might end up hitting Too Many SOQL error and/or Too many DML operations or both through this approach.Solution:
All you would need to do is add 2 assignment steps inside your loop:
- Assign the values from Sobj of Loop to additional Sobj
- Assign the new Sobj to a Sobj collection (ensure you link this back to loop element)
Above two steps would replicate the data in a temporary Sobj Collection, which acts as a replica of bulk values of object itself and do ensure that End of Loop would point to Fast create element (not the Record Create) of OpportunityTeams to create records.Hope this helps. Please mark as best answer if it does.
Cheers!!
Gaurav
All Answers
Could you export the metadata definition of your flow?
The steps you need to follow are explained here (packflow.xml): https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005W9uQAE
Thank you for teaching me how to retrieve the metadata from Workbench. Here is my flow metadata. Thank you!
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<interviewLabel>Add OpportunityTeam to Renewal {!$Flow.CurrentDateTime}</interviewLabel>
<label>Add Opty Team to Renewal</label>
<loops>
<name>Loop_Through_Previous_Year_Opty_Team</name>
<label>Loop Through Previous Year Opty Team</label>
<locationX>285</locationX>
<locationY>370</locationY>
<assignNextValueToReference>PreviousYearOptyTeamMember</assignNextValueToReference>
<collectionReference>PreviousYearOptyTeamMembers</collectionReference>
<iterationOrder>Asc</iterationOrder>
<nextValueConnector>
<targetReference>AddOptyTeamMember</targetReference>
</nextValueConnector>
<noMoreValuesConnector>
<targetReference>Update_Opty</targetReference>
</noMoreValuesConnector>
</loops>
<processType>AutoLaunchedFlow</processType>
<recordCreates>
<name>AddOptyTeamMember</name>
<label>AddOptyTeamMember</label>
<locationX>288</locationX>
<locationY>508</locationY>
<inputAssignments>
<field>CurrencyIsoCode</field>
<value>
<elementReference>PreviousYearOptyTeamMember.CurrencyIsoCode</elementReference>
</value>
</inputAssignments>
<inputAssignments>
<field>OpportunityAccessLevel</field>
<value>
<stringValue>All</stringValue>
</value>
</inputAssignments>
<inputAssignments>
<field>OpportunityId</field>
<value>
<elementReference>varCurrentOptyID</elementReference>
</value>
</inputAssignments>
<inputAssignments>
<field>TeamMemberRole</field>
<value>
<elementReference>PreviousYearOptyTeamMember.TeamMemberRole</elementReference>
</value>
</inputAssignments>
<inputAssignments>
<field>UserId</field>
<value>
<elementReference>PreviousYearOptyTeamMember.UserId</elementReference>
</value>
</inputAssignments>
<object>OpportunityTeamMember</object>
</recordCreates>
<recordLookups>
<name>FindPreviousYearOpty</name>
<label>FindPreviousYearOpty</label>
<locationX>284</locationX>
<locationY>135</locationY>
<assignNullValuesIfNoRecordsFound>true</assignNullValuesIfNoRecordsFound>
<connector>
<targetReference>FindPreviousYearOptyMemberFast</targetReference>
</connector>
<filters>
<field>Id</field>
<operator>EqualTo</operator>
<value>
<elementReference>varCurrentOptyID</elementReference>
</value>
</filters>
<object>Opportunity</object>
<outputAssignments>
<assignToReference>varPreviousYearOptyID</assignToReference>
<field>Previous_Year_Opportunity_ID__c</field>
</outputAssignments>
</recordLookups>
<recordLookups>
<name>FindPreviousYearOptyMemberFast</name>
<label>FindPreviousYearOptyMemberFast</label>
<locationX>280</locationX>
<locationY>252</locationY>
<assignNullValuesIfNoRecordsFound>false</assignNullValuesIfNoRecordsFound>
<connector>
<targetReference>Loop_Through_Previous_Year_Opty_Team</targetReference>
</connector>
<filters>
<field>OpportunityId</field>
<operator>EqualTo</operator>
<value>
<elementReference>varPreviousYearOptyID</elementReference>
</value>
</filters>
<object>OpportunityTeamMember</object>
<outputReference>PreviousYearOptyTeamMembers</outputReference>
<queriedFields>OpportunityId</queriedFields>
<queriedFields>CurrencyIsoCode</queriedFields>
<queriedFields>TeamMemberRole</queriedFields>
<queriedFields>OpportunityAccessLevel</queriedFields>
<queriedFields>UserId</queriedFields>
<sortField>TeamMemberRole</sortField>
<sortOrder>Asc</sortOrder>
</recordLookups>
<recordUpdates>
<name>Update_Opty</name>
<label>Update Opty</label>
<locationX>508</locationX>
<locationY>373</locationY>
<filters>
<field>Id</field>
<operator>EqualTo</operator>
<value>
<elementReference>varCurrentOptyID</elementReference>
</value>
</filters>
<inputAssignments>
<field>RFP_Status__c</field>
<value>
<stringValue>Not Started</stringValue>
</value>
</inputAssignments>
<object>Opportunity</object>
</recordUpdates>
<startElementReference>FindPreviousYearOpty</startElementReference>
<variables>
<name>PreviousYearOptyTeamMember</name>
<dataType>SObject</dataType>
<isCollection>false</isCollection>
<isInput>false</isInput>
<isOutput>false</isOutput>
<objectType>OpportunityTeamMember</objectType>
</variables>
<variables>
<name>PreviousYearOptyTeamMembers</name>
<dataType>SObject</dataType>
<isCollection>true</isCollection>
<isInput>false</isInput>
<isOutput>false</isOutput>
<objectType>OpportunityTeamMember</objectType>
</variables>
<variables>
<name>varCurrentOptyID</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>true</isOutput>
</variables>
<variables>
<name>varPreviousYearOptyID</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>true</isOutput>
</variables>
</Flow>
Your workflow is deployed in my free org. Now, I can have access to all the details without asking you and even test it with exactly all your parameters.
The next post will explain how you can deploy the solution.
1) Modify the file: package.xml
Add_Opty_Team_to_Renewal-2 where 2 is the version and can be changed
the file Add_Opty_Team_to_Renewal-2.flow must exist into the folder: flows (only this file)
2) the folder : "flows" contains now only: Add_Opty_Team_to_Renewal-2.flow (with the source code above)
3) Make a zip file named package.zip with: package.xml and the folder "flows" (reverse operation)
3) Workbench migration > deploy : https://workbench.developerforce.com/metadataDeploy.php
Select the file: package.zip + checkbox: Single Package + button: Next + button: Deploy
That's all and you will have a new version of the flow.
Did you try the "solution" ? You have probably improve it and it is always interesting to have a feed-back.
Thanks
Alain
Reason for your flow not working:
- Record Create element is used to create a single record and not multiple records in bulk.
- Your Record Create is not pointing back to Loop element. This means that your flow stops after the Record Create element
Flaw in your flow is that you are trying to create record within a loop, which is not a recommended approach as you might end up hitting Too Many SOQL error and/or Too many DML operations or both through this approach.Solution:
All you would need to do is add 2 assignment steps inside your loop:
- Assign the values from Sobj of Loop to additional Sobj
- Assign the new Sobj to a Sobj collection (ensure you link this back to loop element)
Above two steps would replicate the data in a temporary Sobj Collection, which acts as a replica of bulk values of object itself and do ensure that End of Loop would point to Fast create element (not the Record Create) of OpportunityTeams to create records.Hope this helps. Please mark as best answer if it does.
Cheers!!
Gaurav
Cheers!!
Gaurav