<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>62.0</apiVersion>
    <areMetricsLoggedToDataCloud>false</areMetricsLoggedToDataCloud>
    <decisions>
        <name>Is_AATS</name>
        <label>Is AATS?</label>
        <locationX>182</locationX>
        <locationY>395</locationY>
        <defaultConnector>
            <targetReference>Update_AATA_Date_Field</targetReference>
        </defaultConnector>
        <defaultConnectorLabel>Adv &amp; Terms Approved</defaultConnectorLabel>
        <rules>
            <name>Adv_Terms_Submitted</name>
            <conditionLogic>and</conditionLogic>
            <conditions>
                <leftValueReference>$Record.StageName</leftValueReference>
                <operator>EqualTo</operator>
                <rightValue>
                    <stringValue>Request Advance Model</stringValue>
                </rightValue>
            </conditions>
            <connector>
                <targetReference>Update_AATS_Date_Field</targetReference>
            </connector>
            <label>Adv &amp; Terms Submitted</label>
        </rules>
    </decisions>
    <decisions>
        <name>Is_CA_Record_Type_and_Specific_Stages</name>
        <label>Is CA Record Type and Specific Stages?</label>
        <locationX>380</locationX>
        <locationY>287</locationY>
        <defaultConnectorLabel>Default Outcome</defaultConnectorLabel>
        <rules>
            <name>Yes</name>
            <conditionLogic>1 AND (2 OR 3)</conditionLogic>
            <conditions>
                <leftValueReference>$Record.RecordType.DeveloperName</leftValueReference>
                <operator>StartsWith</operator>
                <rightValue>
                    <stringValue>Content</stringValue>
                </rightValue>
            </conditions>
            <conditions>
                <leftValueReference>$Record.StageName</leftValueReference>
                <operator>EqualTo</operator>
                <rightValue>
                    <stringValue>Request Advance Model</stringValue>
                </rightValue>
            </conditions>
            <conditions>
                <leftValueReference>$Record.StageName</leftValueReference>
                <operator>EqualTo</operator>
                <rightValue>
                    <stringValue>Advance and Terms Approved</stringValue>
                </rightValue>
            </conditions>
            <connector>
                <targetReference>Is_AATS</targetReference>
            </connector>
            <label>Yes</label>
        </rules>
    </decisions>
    <environments>Default</environments>
    <interviewLabel>CA - Autopopulate Date Fields {!$Flow.CurrentDateTime}</interviewLabel>
    <label>CA - Autopopulate Date Fields</label>
    <processMetadataValues>
        <name>BuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>CanvasMode</name>
        <value>
            <stringValue>AUTO_LAYOUT_CANVAS</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>OriginBuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processType>AutoLaunchedFlow</processType>
    <recordUpdates>
        <name>Update_AATA_Date_Field</name>
        <label>Update AATA Date Field</label>
        <locationX>314</locationX>
        <locationY>503</locationY>
        <inputAssignments>
            <field>CA_Adv_And_Terms_Approved_Date__c</field>
            <value>
                <elementReference>$Flow.CurrentDate</elementReference>
            </value>
        </inputAssignments>
        <inputReference>$Record</inputReference>
    </recordUpdates>
    <recordUpdates>
        <name>Update_AATS_Date_Field</name>
        <label>Update AATS Date Field</label>
        <locationX>50</locationX>
        <locationY>503</locationY>
        <inputAssignments>
            <field>CA_Adv_And_Terms_Submitted_Date__c</field>
            <value>
                <elementReference>$Flow.CurrentDate</elementReference>
            </value>
        </inputAssignments>
        <inputReference>$Record</inputReference>
    </recordUpdates>
    <start>
        <locationX>254</locationX>
        <locationY>0</locationY>
        <connector>
            <targetReference>Is_CA_Record_Type_and_Specific_Stages</targetReference>
        </connector>
        <filterLogic>and</filterLogic>
        <filterFormula>OR(
        ISNEW(),
        ISCHANGED({!$Record.StageName})
        )
        </filterFormula>
        <object>Opportunity</object>
        <recordTriggerType>CreateAndUpdate</recordTriggerType>
        <triggerType>RecordBeforeSave</triggerType>
    </start>
    <status>Active</status>
    <variables>
        <name>CA_Record_Types</name>
        <dataType>String</dataType>
        <isCollection>true</isCollection>
        <isInput>false</isInput>
        <isOutput>false</isOutput>
    </variables>
    <variables>
        <name>RecordTypeId</name>
        <dataType>String</dataType>
        <isCollection>false</isCollection>
        <isInput>false</isInput>
        <isOutput>false</isOutput>
        <value>
            <elementReference>$Record.RecordTypeId</elementReference>
        </value>
    </variables>
</Flow>
