+ Start a Discussion
Rung41Rung41 

Visual Flow help

Hello, I am new to Visual Workflows and trying to develop a flow that will look at the Stage & Type field on all the Opportunities associated with an Account and update a field on the Account record based on the following.

  • If at least one Opportunity has an Approved stage, update the Account field with Approved - Active
  • If the stage of  every Opportunity is Pending, update the Account with Pending
  • If the stage of every Opportunity is Decline, update the Account field with Declined
  • If the stage of every Opportunity is Approved-Not Active, update the Account field with Approved - Not Active
The Flow finishes but the Account record is not updating. I think the fault lies in my decision logic but I am not sure. I have Stage "Approved" set to "One condition must be true" and all the other stages set to "All conditions must be true".  Depending on the decision, I route the logic to the applicable Update Record module

User-added image Flow Diagram

User-added image Fast Lookup. Query all Opportunities with a specific value in the Type field. Assign the records to GetOppID var along with AccountID & StageName
User-added image Decision logic for an Approved Opportunity
User-added image Decision logic for a Declined Opportunity
User-added image Update the Account based on the Approved Decision. The other update modules a built in the same fashion.

Any & all tips or insights are appreciated!

Gaurav HandooGaurav Handoo
Hi

Solution 1:
If you can change the relation between your Accounts and Opportunities to master-child. Following is what you can do:
  1. Take the Roll-up summary count (of Opportunities) on Acconut for each type value. Your different fields would need (nomenclatrue could be based on your requirement):
    1. Total Opportunities (no filter applied)
    2. Opportunities with Status Pending
    3. Opportunities with Status Approved - Not Active
    4. Opportunities with Status Approved
    5. Opportunities with Status Declined
  2. Create a Process Builder on Account Update/Opportunity Update.
    1. Check the condition if count on Total Opportunities and Rest of the counts of Account's field (created in previous step) matches. You would need individual criteria step for each Status.
    2. In action (against each criteria check), update the account's field with your desired value.

Solution 2:
In case, you cannot change the relation to Master-Child, I assume, you would be calling the Flow from Process Builder on every stage change of Opportunity. In that case, following are the changes you would need to incorporate in your flow:
 
Resource TypeNameTypeDefault Value
VariableTotal OpportunitiesNumber0
VariablePending OpportunitiesNumber0
VariableDecline OpportunitiesNumber0
VariableApproved-Not Active OpportunitiesNumber0
VariableActive FoundBooleanFalse
Sobject CollectionFetched OpportunitiesOpportunity 
Sobject VariableL1 Sobj VariableOpportunity 
Sobject VariableL2 Sobj VariableOpportunity 
Sobject VariableUpdate VariableAccount 

User-added image


Hope this helps. If so, please mark as answer.

Cheers!!

Gaurav