
Announcements
I am new to power automate and i didnt found a soultion, on how i can get a random item value out of an array. If tried https://www.flyingpolymath.com/post/expression-interlude-random-item-from-array-in-power-automate ; https://powerusers.microsoft.com/t5/Building-Flows/Help-Selecting-a-random-element-from-array/m-p/956570#M134082 and several other things, but somehow i dont get it done.
Idea: The goal would be to select from an excel list, all rows which have an empty value in a specific column. Then select from this subset/array an random item and get the value"Number"/"Nummer" from this item. (Later this item would be changed in the excel list and filled out with some MS-Forms data).
Flow: So i get the excel list from my onedrive folder (works sucessful), then get the subset out of the excel list with an array filter (works sucessful) and then try with the action "compose" to get an random item out of the array (doenst work).
I have entered the expression in the compose action to get an random item by myself.
Problem:
I tried the following expression:
body('Freie_Nummern')?['body'][rand(0, length(body('Freie_Nummern')?['body']))]?['Nummer']
Since it didnt worked, i tried to simplify it and only get an whole array-item, with the following code:
body('Freie_Nummern')?['body'][0]body('Freie_Nummern')?['value'][0]
But also with this "easy" expression, the error-report always says, that i have to select an array element with an integer expressions. So i think, that somehow i am not using the correct attribute with "body" or "value". Could somebody point my to the correct syntax i would need to use? Thanks and sorry for the long text: )
Flow:
Error Message:
German: Vorlagensprachausdrücke in den Eingaben der Aktion "Verfassen" in Zeile "0" und Spalte "0" können nicht verarbeitet werden: Der Vorlagensprachausdruck "body('Freie_Nummern')?['body'][0]" kann nicht ausgewertet werden, weil die Eigenschaft "body" nicht ausgewählt werden kann. Arrayelemente können nur mit einem Ganzzahlindex ausgewählt werden. Weitere Informationen zur Verwendung finden Sie unter https://aka.ms/logicexpressions..
English: Template language expressions in the inputs of the "Compose" action in row "0" and column "0" cannot be processed: The template language expression "body('Free_Numbers')?['body'][0]" cannot be evaluated because the "body" property cannot be selected. Array elements can only be selected with an integer index. For more information on usage, see https://aka.ms/logicexpressions..