<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>63.0</apiVersion>
    <assignments>
        <name>Build_Record</name>
        <label>Build Record</label>
        <locationX>0</locationX>
        <locationY>0</locationY>
        <assignmentItems>
            <assignToReference>varRecord.mdpick__Schedule_Date__c</assignToReference>
            <operator>Assign</operator>
            <value>
                <elementReference>fDay</elementReference>
            </value>
        </assignmentItems>
        <assignmentItems>
            <assignToReference>varRecord.mdpick__Event__c</assignToReference>
            <operator>Assign</operator>
            <value>
                <elementReference>recordId</elementReference>
            </value>
        </assignmentItems>
        <assignmentItems>
            <assignToReference>varRecord.mdpick__Schedule_Name__c</assignToReference>
            <operator>Assign</operator>
            <value>
                <stringValue>Time off</stringValue>
            </value>
        </assignmentItems>
        <assignmentItems>
            <assignToReference>colRecords</assignToReference>
            <operator>Add</operator>
            <value>
                <elementReference>varRecord</elementReference>
            </value>
        </assignmentItems>
        <connector>
            <targetReference>Loop_Days</targetReference>
        </connector>
    </assignments>
    <description>Starter flow from the MultiDatePick blog (Flow loops). Pick days and ranges on one screen, then save one Schedule record for every single day, ranges included, in a single Create Records step after the loop. No parser: it loops over the calendar's day list. Launch it from an Event record to link every record to it (recordId). Set the calendar's Config Name on the Pick Dates screen, and swap the object and fields for your own.</description>
    <formulas>
        <name>fDay</name>
        <dataType>Date</dataType>
        <expression>DATEVALUE({!Loop_Days})</expression>
    </formulas>
    <interviewLabel>MDP Starter - Record per Day {!$Flow.CurrentDateTime}</interviewLabel>
    <label>MDP Starter - Record per Day</label>
    <loops>
        <name>Loop_Days</name>
        <label>Loop Days</label>
        <locationX>0</locationX>
        <locationY>0</locationY>
        <collectionReference>varDays</collectionReference>
        <iterationOrder>Asc</iterationOrder>
        <nextValueConnector>
            <targetReference>Build_Record</targetReference>
        </nextValueConnector>
        <noMoreValuesConnector>
            <targetReference>Save_Records</targetReference>
        </noMoreValuesConnector>
    </loops>
    <processMetadataValues>
        <name>BuilderType</name>
        <value>
            <stringValue>LightningFlowBuilder</stringValue>
        </value>
    </processMetadataValues>
    <processMetadataValues>
        <name>CanvasMode</name>
        <value>
            <stringValue>AUTO_LAYOUT_CANVAS</stringValue>
        </value>
    </processMetadataValues>
    <processType>Flow</processType>
    <recordCreates>
        <name>Save_Records</name>
        <label>Save Records</label>
        <locationX>0</locationX>
        <locationY>0</locationY>
        <connector>
            <targetReference>Done</targetReference>
        </connector>
        <inputReference>colRecords</inputReference>
    </recordCreates>
    <screens>
        <name>Done</name>
        <label>Done</label>
        <locationX>0</locationX>
        <locationY>0</locationY>
        <allowBack>false</allowBack>
        <allowFinish>true</allowFinish>
        <allowPause>false</allowPause>
        <fields>
            <name>Done_Text</name>
            <fieldText>&lt;p&gt;Records saved.&lt;/p&gt;</fieldText>
            <fieldType>DisplayText</fieldType>
        </fields>
        <showFooter>true</showFooter>
        <showHeader>true</showHeader>
    </screens>
    <screens>
        <name>Pick_Dates</name>
        <label>Pick Dates</label>
        <locationX>0</locationX>
        <locationY>0</locationY>
        <allowBack>false</allowBack>
        <allowFinish>true</allowFinish>
        <allowPause>false</allowPause>
        <connector>
            <targetReference>Loop_Days</targetReference>
        </connector>
        <fields>
            <name>Date_Calendar</name>
            <extensionName>mdpick:multiDatePickDates</extensionName>
            <fieldType>ComponentInstance</fieldType>
            <isRequired>true</isRequired>
            <outputParameters>
                <assignToReference>varDays</assignToReference>
                <name>selectedDates</name>
            </outputParameters>
        </fields>
        <showFooter>true</showFooter>
        <showHeader>true</showHeader>
    </screens>
    <start>
        <locationX>50</locationX>
        <locationY>0</locationY>
        <connector>
            <targetReference>Pick_Dates</targetReference>
        </connector>
    </start>
    <status>Draft</status>
    <variables>
        <name>colRecords</name>
        <dataType>SObject</dataType>
        <isCollection>true</isCollection>
        <isInput>false</isInput>
        <isOutput>false</isOutput>
        <objectType>mdpick__Schedule__c</objectType>
    </variables>
    <variables>
        <name>recordId</name>
        <dataType>String</dataType>
        <isCollection>false</isCollection>
        <isInput>true</isInput>
        <isOutput>false</isOutput>
    </variables>
    <variables>
        <name>varDays</name>
        <dataType>String</dataType>
        <isCollection>true</isCollection>
        <isInput>false</isInput>
        <isOutput>false</isOutput>
    </variables>
    <variables>
        <name>varRecord</name>
        <dataType>SObject</dataType>
        <isCollection>false</isCollection>
        <isInput>false</isInput>
        <isOutput>false</isOutput>
        <objectType>mdpick__Schedule__c</objectType>
    </variables>
</Flow>
