<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>63.0</apiVersion>
    <areMetricsLoggedToDataCloud>false</areMetricsLoggedToDataCloud>
    <decisions>
        <name>Check_RecordTypes</name>
        <label>Check RecordTypes</label>
        <locationX>314</locationX>
        <locationY>287</locationY>
        <defaultConnectorLabel>Else</defaultConnectorLabel>
        <rules>
            <name>AWAL_RT</name>
            <conditionLogic>and</conditionLogic>
            <conditions>
                <leftValueReference>$Record.RecordType.DeveloperName</leftValueReference>
                <operator>EqualTo</operator>
                <rightValue>
                    <stringValue>AWAL</stringValue>
                </rightValue>
            </conditions>
            <connector>
                <targetReference>Update_AWAL_Currency</targetReference>
            </connector>
            <label>AWAL RT</label>
        </rules>
        <rules>
            <name>CA_RT_s</name>
            <conditionLogic>and</conditionLogic>
            <conditions>
                <leftValueReference>$Record.RecordType.DeveloperName</leftValueReference>
                <operator>StartsWith</operator>
                <rightValue>
                    <stringValue>Content</stringValue>
                </rightValue>
            </conditions>
            <connector>
                <targetReference>Update_CA_Currency</targetReference>
            </connector>
            <label>CA RT&apos;s</label>
        </rules>
    </decisions>
    <environments>Default</environments>
    <formulas>
        <name>CACurrencyFormated</name>
        <dataType>String</dataType>
        <expression>IF(
  AND(
    NOT(ISBLANK(TEXT({!$Record.CA_Currency__c}))),
    BEGINS({!$Record.RecordType.DeveloperName}, &quot;Content&quot;),
    CONTAINS(TEXT({!$Record.CA_Currency__c}), &quot;(&quot;),
    CONTAINS(TEXT({!$Record.CA_Currency__c}), &quot;)&quot;)
  ),
  MID(
    TEXT({!$Record.CA_Currency__c}),
    FIND(&quot;(&quot;, TEXT({!$Record.CA_Currency__c})) + 1,
    FIND(&quot;)&quot;, TEXT({!$Record.CA_Currency__c})) - FIND(&quot;(&quot;, TEXT({!$Record.CA_Currency__c})) - 1
  ),
  &quot;&quot;
)</expression>
    </formulas>
    <interviewLabel>Update Opportunity Currency Field {!$Flow.CurrentDateTime}</interviewLabel>
    <label>Update Opportunity Currency Field</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_AWAL_Currency</name>
        <label>Update AWAL Currency</label>
        <locationX>50</locationX>
        <locationY>395</locationY>
        <inputAssignments>
            <field>CurrencyIsoCode</field>
            <value>
                <elementReference>$Record.OpportunityCurrency__c</elementReference>
            </value>
        </inputAssignments>
        <inputReference>$Record</inputReference>
    </recordUpdates>
    <recordUpdates>
        <name>Update_CA_Currency</name>
        <label>Update CA Currency</label>
        <locationX>314</locationX>
        <locationY>395</locationY>
        <inputAssignments>
            <field>CurrencyIsoCode</field>
            <value>
                <elementReference>CACurrencyFormated</elementReference>
            </value>
        </inputAssignments>
        <inputReference>$Record</inputReference>
    </recordUpdates>
    <start>
        <locationX>188</locationX>
        <locationY>0</locationY>
        <connector>
            <targetReference>Check_RecordTypes</targetReference>
        </connector>
        <filterLogic>or</filterLogic>
        <filters>
            <field>OpportunityCurrency__c</field>
            <operator>IsChanged</operator>
            <value>
                <booleanValue>true</booleanValue>
            </value>
        </filters>
        <filters>
            <field>CA_Currency__c</field>
            <operator>IsChanged</operator>
            <value>
                <booleanValue>true</booleanValue>
            </value>
        </filters>
        <filters>
            <field>Id</field>
            <operator>IsNull</operator>
            <value>
                <booleanValue>true</booleanValue>
            </value>
        </filters>
        <object>Opportunity</object>
        <recordTriggerType>CreateAndUpdate</recordTriggerType>
        <triggerType>RecordBeforeSave</triggerType>
    </start>
    <status>Active</status>
</Flow>
