<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>59.0</apiVersion>
    <description>Record-triggered Flow on Account (after create and after update of AnnualRevenue). Logic: Evaluate AnnualRevenue and assign Customer_Tier__c per mapping table. Also includes a scheduled path for backfill of existing Accounts.</description>
    <interviewLabel>Account_Customer_Tier_Assignment {!$Flow.CurrentDateTime}</interviewLabel>
    <label>Account Customer Tier Assignment</label>
    <processMetadataValues>
        <name>BuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processType>AutoLaunchedFlow</processType>
    <start>
        <locationX>50</locationX>
        <locationY>0</locationY>
        <object>Account</object>
        <recordTriggerType>CreateAndUpdate</recordTriggerType>
        <triggerType>RecordAfterSave</triggerType>
        <connector>
            <targetReference>Assign_Tier</targetReference>
        </connector>
    </start>
    <variables>
        <name>varAccount</name>
        <dataType>SObject</dataType>
        <isCollection>false</isCollection>
        <isInput>true</isInput>
        <isOutput>false</isOutput>
        <objectType>Account</objectType>
    </variables>
    <assignments>
        <name>Assign_Tier</name>
        <label>Assign Customer Tier</label>
        <locationX>176</locationX>
        <locationY>134</locationY>
        <assignmentItems>
            <assignToReference>{!$Record.Customer_Tier__c}</assignToReference>
            <operator>Assign</operator>
            <value>
                <formula>
                    IF(
                        {!$Record.AnnualRevenue} &gt;= 1000000, "Platinum",
                        IF(
                            {!$Record.AnnualRevenue} &gt;= 100000, "Gold",
                            IF(
                                {!$Record.AnnualRevenue} &gt;= 10000, "Silver",
                                "Bronze"
                            )
                        )
                    )
                </formula>
            </value>
        </assignmentItems>
    </assignments>
    <scheduledPaths>
        <name>Backfill_Existing_Accounts</name>
        <label>Backfill Existing Accounts</label>
        <schedule>
            <frequency>Once</frequency>
            <startDateTime>{!$Flow.CurrentDateTime}</startDateTime>
        </schedule>
        <connector>
            <targetReference>Assign_Tier</targetReference>
        </connector>
    </scheduledPaths>
    <status>Active</status>
</Flow>
