
Hi Community,
I have the following power automate (PA) flow I was able to build following partially the instructions from Awesome! Create Charts via Office Scripts - DamoBird365
I have adapted the excel script to export existing charts in excel (instead of creating them with the script) to a word template. My question will concern the script in the "run script" action and probably also the "compose action".
The script code is the following which comes from the microsoft doc to illustrate the getImage property. I have just adapted it to include a second chart:
The PA workflow works very well when a single image is used. However, I have not been able to include the second image in my workflow. I am not expert at coding so I just tested crating 2 "return" as you can see at the end of the previous script, but only the first image is really taken into account in the PA workflow.
The other thing I tested is returning an array :
but in this case I get an error when running the PA workflow:
I have also tried creating and interface at the end as I have seem in other examples of code in the microsoft doc :
but in this case I get another error :
Do you know how I can correctly return my two images from my script to then be able to use them in the rest of my PA workflow ?
Thanks for any help,
Julian
Hi Julian,
When you are returning object with syntax
return { firstimage, secondimage};
then you also need to modify the return type from the function definition, so modify the first line of the function to return interface 'ReportImages' instead of sting as shown below:
function main(workbook: ExcelScript.Workbook): ReportImages {
Pls retest the flow after making the changes.
If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.