Get property value from object array returned by excel script

Raúl Andrés Duque Murillo 236 Reputation points
2021-11-30T23:39:00.233+00:00

Hello,

I have the following flow piece:

153844-image.png

The block Run script (Get data from the Customer Workbook) is returning an array of objects:

*function main(workbook: ExcelScript.Workbook): WorksheetData[]

interface WorksheetData {
customer: string;
customerid: string;
nrows: number;
data: string[][];
}*

The issues I'm experimenting is I haven't been able to find a way to get the nrows property value of the 1st array element, it is required to increment a variable in the loop.

If I include directly the property, I'm getting a for each block:

153873-image.png

I have tried with different options in an expression, but no luck, e.g.:

outputs('Run_script_(Get_data_from_the_Customer_Workbook)')?['body/result'][0].nrows
first(outputs('Run_script_(Get_data_from_the_Customer_Workbook)')?['body/result']).nrows
outputs('Run_script_(Get_data_from_the_Customer_Workbook)')?['body/result'])?['nrows']

Any hint will be welcome.

Here an example of the object (json) returned:

{
"result": [
{
"customer": "VW",
"customerid": "VWID",
"nrows": 4,
"data": [
[
"VW BRANCH ONE",
"PL",
"Travel",
"VWBRANCH01"
],
[
"VW BRANCH TWO",
"DE",
"Travel",
"VWBRANCH02"
],
[
"VW BRANCH THREE",
"DE",
"Expense",
"VWBRANCH03"
],
[
"VW BRANCH FOUR",
"MX",
"Travel",
"VWBRANCH04"
]
]
}
],
"logs": [
"[2021-11-30T22:03:32.7650Z] [{\"customer\":\"VW\",\"customerid\":\"VWID\",\"nrows\":4,\"data\":[[\"VW BRANCH ONE\",\"PL\",\"Travel\",\"VWBRANCH01\"],[\"VW BRANCH TWO\",\"DE\",\"Travel\",\"VWBRANCH02\"],[\"VW BRANCH THREE\",\"DE\",\"Expense\",\"VWBRANCH03\"],[\"VW BRANCH FOUR\",\"MX\",\"Travel\",\"VWBRANCH04\"]]}]"
]
}

Microsoft 365 and Office Development Other
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.