Hi all,
I'm hoping someone can help with the following issue when attempting to write from an Array to a SharePoint list, based on the total number of records in the Array.
The Array (arrayCoreMods) will be of indeterminate length (on the basis of the number of items a user checks on a 'Checkbox' style question on a source Microsoft Form). I know how to determine the total number of items in the Array, using Length, and also how to select a specific record with the Array, for example the first item when the Array is placed inside a Compose action named 'ComposearrayCoreMods' by using: (outputs('ComposearrayCoreMods')[0]).
The issue is how to create a 'best practice' (lean) Flow to write each individual record of the Array into an individual SharePoint List column, stopping at the last item in the Array. The attached diagram shows that the first value from the Array (at Position 0) should be recorded in column Module01, the second value from the Array (at Position 1) should be recorded in column Module02, etc. As the Array will be of indeterminate length, there might be only these two columns to write, or the process could continue to Module03, Module04 and so on.
The problem is, as the expression 'outputs('ComposearrayCoreMods')[0]' has a fixed value to determine the record to retrieve from the Array, in theory, that expression could just be added to each column in the SharePoint list with the Array record position hardcoded in to the [ ] section. So for example:
Module01: 'outputs('ComposearrayCoreMods')[0]'
Module02: 'outputs('ComposearrayCoreMods')[1]' etc.
However, this does not work as when the Array is empty, for example, outputs('ComposearrayCoreMods')[2], there is nothing to write to the SharePoint list and the Flow Fails.
I was wondering if a 'Do Until' statement might help, where two variables compare the current Array position to the total number of items in the Array, however this then introduces the issue of how to formulate the 'Update Item' SharePoint action, as even using a Dynamic Value for the Array position in the outputs statement ( outputs('ComposearrayCoreMods')[variables('varArrayPosition')] ) would not work as each time the action ran this number would be updated and the incorrect data would be written.
I'm sure there's a simple explanation for this but I'm not seeing it and as this is quite specific I ran out of terms to try and search for a solution. Many thanks for your help!