I'm using process builder to auto launch a flow. I pass an id to the flow and use the
getRecords element to query for a collection of records that returns the records in descending order based on a datetime field. What I'm trying to do is loop over the records and assign the next/previous records into lookup fields that exist on the same sObject.
For example, if I have 5 records, the first record wouldn't have a next__c record, but I would need to grab the 2nd index in the collection to populate the previous__c field of the current record in loop. When I loop over the 2nd iteration in the collection, I would need to access the 1st index of the collection to populate the next__c field value and then the 3rd index of the collection to populate the previous__c field value. Is there a way to access the collection indexes? Or, some other way to accomplish this using flow? Or, do I have to resort to Apex to handle this process?