<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>60.0</apiVersion>
    <decisions>
        <name>PaymentReceivedDataChanged</name>
        <label>Payment Received Data Changed</label>
        <locationX>702</locationX>
        <locationY>414</locationY>
        <defaultConnectorLabel>Do Nothing</defaultConnectorLabel>
        <rules>
            <name>YesAndNotNull</name>
            <conditionLogic>and</conditionLogic>
            <conditions>
                <leftValueReference>$Record.PaymentReceivedDate__c</leftValueReference>
                <operator>IsChanged</operator>
                <rightValue>
                    <booleanValue>true</booleanValue>
                </rightValue>
            </conditions>
            <conditions>
                <leftValueReference>$Record.PaymentReceivedDate__c</leftValueReference>
                <operator>IsNull</operator>
                <rightValue>
                    <booleanValue>false</booleanValue>
                </rightValue>
            </conditions>
            <connector>
                <targetReference>RecordToBeChanged</targetReference>
            </connector>
            <label>Yes and Payment Received Date Is not Null</label>
        </rules>
        <rules>
            <name>YesAndPaymentReceivedDateIsNull</name>
            <conditionLogic>and</conditionLogic>
            <conditions>
                <leftValueReference>$Record.PaymentReceivedDate__c</leftValueReference>
                <operator>IsChanged</operator>
                <rightValue>
                    <booleanValue>true</booleanValue>
                </rightValue>
            </conditions>
            <conditions>
                <leftValueReference>$Record.PaymentReceivedDate__c</leftValueReference>
                <operator>IsNull</operator>
                <rightValue>
                    <booleanValue>true</booleanValue>
                </rightValue>
            </conditions>
            <connector>
                <targetReference>Get_Old_Payment_Received_Date_Value</targetReference>
            </connector>
            <label>Yes and Payment Received Date Is Null</label>
        </rules>
    </decisions>
    <environments>Default</environments>
    <interviewLabel>Synch - Update Payment Status {!$Flow.CurrentDateTime}</interviewLabel>
    <label>Synch - Update Payment Status</label>
    <processMetadataValues>
        <name>BuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>CanvasMode</name>
        <value>
            <stringValue>FREE_FORM_CANVAS</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>OriginBuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processType>AutoLaunchedFlow</processType>
    <recordLookups>
        <name>Get_Old_Payment_Received_Date_Value</name>
        <label>Get Old Payment Received Date Value</label>
        <locationX>716</locationX>
        <locationY>633</locationY>
        <assignNullValuesIfNoRecordsFound>false</assignNullValuesIfNoRecordsFound>
        <connector>
            <targetReference>Update_record</targetReference>
        </connector>
        <filterLogic>and</filterLogic>
        <filters>
            <field>ParentId</field>
            <operator>EqualTo</operator>
            <value>
                <elementReference>$Record.Id</elementReference>
            </value>
        </filters>
        <filters>
            <field>Field</field>
            <operator>EqualTo</operator>
            <value>
                <stringValue>PaymentStatus__c</stringValue>
            </value>
        </filters>
        <getFirstRecordOnly>true</getFirstRecordOnly>
        <object>SynchClearance__History</object>
        <sortField>CreatedDate</sortField>
        <sortOrder>Desc</sortOrder>
        <storeOutputAutomatically>true</storeOutputAutomatically>
    </recordLookups>
    <recordUpdates>
        <name>RecordToBeChanged</name>
        <label>Record To Be Changed</label>
        <locationX>256</locationX>
        <locationY>416</locationY>
        <inputAssignments>
            <field>PaymentStatus__c</field>
            <value>
                <stringValue>Payment Received; Completed</stringValue>
            </value>
        </inputAssignments>
        <inputReference>$Record</inputReference>
    </recordUpdates>
    <recordUpdates>
        <name>Update_record</name>
        <label>Update record</label>
        <locationX>716</locationX>
        <locationY>868</locationY>
        <inputAssignments>
            <field>PaymentStatus__c</field>
            <value>
                <elementReference>Get_Old_Payment_Received_Date_Value.OldValue</elementReference>
            </value>
        </inputAssignments>
        <inputReference>$Record</inputReference>
    </recordUpdates>
    <start>
        <locationX>562</locationX>
        <locationY>48</locationY>
        <connector>
            <targetReference>PaymentReceivedDataChanged</targetReference>
        </connector>
        <object>SynchClearance__c</object>
        <recordTriggerType>CreateAndUpdate</recordTriggerType>
        <triggerType>RecordAfterSave</triggerType>
    </start>
    <status>Active</status>
</Flow>
