function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brianna BrownBrianna Brown 

An unhandled fault has occurred in this flow

I'm attempting to use a loop element in a flow I have created. My goal is to populate a custom lookup field on the Account record that looksup to the contact on the last closed opportunity. I'm not sure where my flow is going wrong, but when I select run, I get a message that there is an unhandled fault.

I have included an image of my flow below:

Update Accounts Flow

Thanks for the help!
Alain CabonAlain Cabon
Hi,

You can export the definition of your flow easily with a workbench so other people can analyze and even import it completely effortless.

1) Create this text file: packflow.xml with the content below  (ie: c:\temp\packflow.xml) (very easy)

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>Flow</name>
    </types>
    <version>41.0</version>
</Package>

2) Connect to the workbench (production or sandbox) with the credentials of your used org (if needed) (very easy)

https://workbench.developerforce.com/login.php

3) Menu: migration > retrieve 

4) Select the created file for the Unpackaged Manifest : packflow.xml  and button: Next

User-added image
5) Button:  Retrieve

User-added image

6) Link: Download ZIP File 
User-added image
7) Open the downloaded ZIP File and extract all the files.

8) Copy/paste here the content of the file:  <your flow name>-<version>.flow

I will know everything (100%) of your flow definition. I can read all the details of your flow directly from the metadata definition.

An example of Declarative Metadata Definition is shown here at the bottom of the page:
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_visual_workflow.htm

 
Brianna BrownBrianna Brown
Hi Alain! Thanks for getting back to me. I've followed the above steps and pasted below. I read through the error message I received after running the flow, and I have deduced the issue is that there are some opportunities that do not have an associated contact and that is causing an error. Do you have an idea of how to get around this?

<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <assignments>
        <name>Add_to_Update_Collection</name>
        <label>Add to Update Collection</label>
        <locationX>675</locationX>
        <locationY>497</locationY>
        <assignmentItems>
            <assignToReference>UpdateAccounts</assignToReference>
            <operator>Add</operator>
            <value>
                <elementReference>so_Account</elementReference>
            </value>
        </assignmentItems>
        <connector>
            <targetReference>Loop_Accounts_with_Closed_Opps</targetReference>
        </connector>
    </assignments>
    <assignments>
        <name>Update_Contact</name>
        <label>Update_Contact</label>
        <locationX>680</locationX>
        <locationY>316</locationY>
        <assignmentItems>
            <assignToReference>so_Account.Primary_Contact__c</assignToReference>
            <operator>Assign</operator>
            <value>
                <elementReference>v_ContactId</elementReference>
            </value>
        </assignmentItems>
        <connector>
            <targetReference>Add_to_Update_Collection</targetReference>
        </connector>
    </assignments>
    <interviewLabel>Mass Update  {!$Flow.CurrentDateTime}</interviewLabel>
    <label>Mass Update Accounts with Closed Opps_V2</label>
    <loops>
        <name>Loop_Accounts_with_Closed_Opps</name>
        <label>Loop Accounts with Closed Opps</label>
        <locationX>56</locationX>
        <locationY>280</locationY>
        <assignNextValueToReference>so_Account</assignNextValueToReference>
        <collectionReference>soColl_Accounts</collectionReference>
        <iterationOrder>Asc</iterationOrder>
        <nextValueConnector>
            <targetReference>Last_Closed_Opp</targetReference>
        </nextValueConnector>
        <noMoreValuesConnector>
            <targetReference>Accounts</targetReference>
        </noMoreValuesConnector>
    </loops>
    <processType>AutoLaunchedFlow</processType>
    <recordLookups>
        <name>Last_Closed_Opp</name>
        <label>Last Closed Opp</label>
        <locationX>282</locationX>
        <locationY>120</locationY>
        <assignNullValuesIfNoRecordsFound>false</assignNullValuesIfNoRecordsFound>
        <connector>
            <targetReference>Look_Up_Contact_Role</targetReference>
        </connector>
        <filters>
            <field>AccountId</field>
            <operator>EqualTo</operator>
            <value>
                <elementReference>so_Account.Id</elementReference>
            </value>
        </filters>
        <filters>
            <field>CloseDate</field>
            <operator>EqualTo</operator>
            <value>
                <elementReference>so_Account.Most_Recent_Opportunit__c</elementReference>
            </value>
        </filters>
        <object>Opportunity</object>
        <outputAssignments>
            <assignToReference>v_OpportunityID</assignToReference>
            <field>Id</field>
        </outputAssignments>
    </recordLookups>
    <recordLookups>
        <name>Look_up_Account_with_Closed_Opp</name>
        <label>Look up Account with Closed Opp</label>
        <locationX>53</locationX>
        <locationY>154</locationY>
        <assignNullValuesIfNoRecordsFound>false</assignNullValuesIfNoRecordsFound>
        <connector>
            <targetReference>Loop_Accounts_with_Closed_Opps</targetReference>
        </connector>
        <filters>
            <field>Opportunity_Amount_Total__c</field>
            <operator>GreaterThan</operator>
            <value>
                <numberValue>0.0</numberValue>
            </value>
        </filters>
        <object>Account</object>
        <outputReference>soColl_Accounts</outputReference>
        <queriedFields>Id</queriedFields>
        <queriedFields>Most_Recent_Opportunit__c</queriedFields>
        <queriedFields>Primary_Contact__c</queriedFields>
    </recordLookups>
    <recordLookups>
        <name>Look_Up_Contact_Role</name>
        <label>Look Up Contact Role</label>
        <locationX>497</locationX>
        <locationY>126</locationY>
        <assignNullValuesIfNoRecordsFound>false</assignNullValuesIfNoRecordsFound>
        <connector>
            <targetReference>Lookup_Contact</targetReference>
        </connector>
        <filters>
            <field>OpportunityId</field>
            <operator>EqualTo</operator>
            <value>
                <elementReference>v_OpportunityID</elementReference>
            </value>
        </filters>
        <object>OpportunityContactRole</object>
        <outputAssignments>
            <assignToReference>v_ContactId</assignToReference>
            <field>ContactId</field>
        </outputAssignments>
    </recordLookups>
    <recordLookups>
        <name>Lookup_Contact</name>
        <label>Lookup Contact</label>
        <locationX>669</locationX>
        <locationY>123</locationY>
        <assignNullValuesIfNoRecordsFound>false</assignNullValuesIfNoRecordsFound>
        <connector>
            <targetReference>Update_Contact</targetReference>
        </connector>
        <filters>
            <field>Id</field>
            <operator>EqualTo</operator>
            <value>
                <elementReference>v_ContactId</elementReference>
            </value>
        </filters>
        <object>Contact</object>
        <outputAssignments>
            <assignToReference>v_Inactive</assignToReference>
            <field>Inactive__c</field>
        </outputAssignments>
    </recordLookups>
    <recordUpdates>
        <name>Accounts</name>
        <label>Accounts</label>
        <locationX>54</locationX>
        <locationY>413</locationY>
        <inputReference>UpdateAccounts</inputReference>
    </recordUpdates>
    <startElementReference>Look_up_Account_with_Closed_Opp</startElementReference>
    <variables>
        <name>so_Account</name>
        <dataType>SObject</dataType>
        <isCollection>false</isCollection>
        <isInput>true</isInput>
        <isOutput>true</isOutput>
        <objectType>Account</objectType>
    </variables>
    <variables>
        <name>soColl_Accounts</name>
        <dataType>SObject</dataType>
        <isCollection>true</isCollection>
        <isInput>true</isInput>
        <isOutput>true</isOutput>
        <objectType>Account</objectType>
    </variables>
    <variables>
        <name>UpdateAccounts</name>
        <dataType>SObject</dataType>
        <isCollection>true</isCollection>
        <isInput>true</isInput>
        <isOutput>true</isOutput>
        <objectType>Account</objectType>
    </variables>
    <variables>
        <name>v_ContactId</name>
        <dataType>String</dataType>
        <isCollection>false</isCollection>
        <isInput>true</isInput>
        <isOutput>true</isOutput>
    </variables>
    <variables>
        <name>v_Inactive</name>
        <dataType>Boolean</dataType>
        <isCollection>false</isCollection>
        <isInput>true</isInput>
        <isOutput>true</isOutput>
    </variables>
    <variables>
        <name>v_OpportunityID</name>
        <dataType>String</dataType>
        <isCollection>false</isCollection>
        <isInput>true</isInput>
        <isOutput>true</isOutput>
    </variables>
</Flow>
 
Alain CabonAlain Cabon
Hi Brianna,

I can do the exact opposite operation called "deploy" with the workbench now.

User-added image


User-added image

And I have exactly your flow in my free developer org so I can test it directly if necessary.

I will let you know as soon as everything is clarified.
 
Alain CabonAlain Cabon
If I launch your flow directly, there is no error with my few opportunities.

You can also see the log of your workflow launching it with Developer Console open.

User-added image

User-added image

User-added image


You have used a very large scope for the main Fast Lookup : all the accounts with Opportunity_Amount_Total__c > 0

User-added image

You can do that in "theory" but that could exceed the governor limits.

What is the content of your log?
 
Brianna BrownBrianna Brown
Hi Alain,

Thanks for testing. Where can I find the content of my log?

Best,

Brianna
Alain CabonAlain Cabon
If you have a sandbox:

a) To open the Developer Console from Salesforce Classic:
  1. Click Your Name.
  2. Click Developer Console.
b) Run your flow
c) Select the tab: Logs (like above) and double-click where your see /flow/... in the Developer Console

I will continue to look at your imported flow but it could already be fine.