This describes, how to take value from Office Script and send it to Power Automate flow, which will use it.

Office Script generating values

Lets say you have this script Office Script:

  • function main(workbook: ExcelScript.Workbook,
    )
    {
    console.log(1) //console output
    return(2) // result
    }

It generates two values – console output (number 1) and content of return function (number 2).

Use in Power Automate

The input for Power Automate is a “Body” object with this content:
  • {“result”:2,”logs”:[“[2022-11-09T18:57:34.1580Z] 1“]}

which is quite difficult to read, it would be better to keep “results” and “logs” separately.

In Power Automate we will use the Parse JSON step, which splits the body into components.

then we can reference these JSON components from any following step:

For example, this generates this mail:

 

Leave a Reply

Your email address will not be published.

*

clear formPost comment