web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow sending old versi...
Power Automate
Unanswered

Flow sending old version of chart by email

(0) ShareShare
ReportReport
Posted on by

Hi, I'm really struggling with a flow I created...

I searched a lot and finally could build a flow to update a table in excel so an Excel Script will generate an image of a chart (related to the updated table) and send it by email. It´s like a Frankenstein of tutorials that I've seen. 

 

But... the problem is: The flow theoretically works like a charm, but sometimes it happens that I send an old version of this chart, instead of the updated version of it. I'm an Excel and Power Automate novice and trying my best to solve this. I tried to insert some delay time between some flow steps, I tried to execute the script twice before sending the e-mail, I tried to make some changes in the script, but I just can´t guarantee that the flow will send a proper version of my chart. 

 

The script tutorial that worked for what I wanted: https://www.youtube.com/watch?v=6LEgVBZ4TyQ&list=LL&index=1   

My script:

function main(workbook: ExcelScript.Workbook,
    wsName: string,
    objType: string,
    objName: string) {

 

    //Declare the variables
    let ws = workbook.getWorksheet(wsName);
    let base64: string;
    let base64Img: string;
    let base64ImgHTML: string;

 

// Beginning of my 'Improvements' 
  let selectedSheet = workbook.getWorksheet(wsName);

 

  // Set range C2 on selectedSheet
  selectedSheet.getRange("C2").setFormulaLocal("=PROCV(TEXTO(B2,\"0\"),'Resultado!'!A:Z,16,0)");

 

  // Set range D2 on selectedSheet
  selectedSheet.getRange("D2").setFormulaLocal("=PROCV(TEXTO(B2,\"0\"),'Resultado!'!A:Z,17,0)");

 

  // Set range E2 on selectedSheet
  selectedSheet.getRange("E2").setFormulaLocal("=PROCV(TEXTO(B2,\"0\"),'Resultado!'!A:AB,28,0)");
// End of my 'Improvements' 

 

    //Return image from range or change based on request
    if (objType == "Range") {
        base64 = ws.getRange(objName).getImage();
    } else if (objType == "Chart") {
        base64 = ws.getChart(objName).getImage();
    } else if (objType == "Shape") {
        base64 = ws.getShape(objName).
            getImageAsBase64(ExcelScript.PictureFormat.png);
    }

 

    //Add image type to the pure base64
    base64Img = "data:image/png;base64," + base64

 

    //Add HTML tags to base64 imgBase64
    base64ImgHTML = '<img src="' + base64Img + '"/>'

 

    //Return the result
    return { base64, base64Img, base64ImgHTML }

 

}

I don´t want to generate a new chart (it´s the usual solution around) because I need an specific background image in my chart and Excel web doesn´t enable that. 

Can anyone explain why this is happening and how to solve it?

 

Thank you all!

Categories:
I have the same question (0)
  • PowerQuests Profile Picture
    2 on at

    hi @GuilhermeSimões ,

     

    for a moment i thought i was the one who post the question , haha because it's exactly what i did and what i'm facing right now !!

     

    from all videos and articles i did read, they always create and then delete the graph from the script , they didn't say directly that it would be a solution for the case , but it seems to wok fine. 

     

    did you find another solution , perhaps ? tell me !

    because that approach don't correspond to my needs  (i need to make an image as background to the chart, but don't find a solution yet with office script)

     

    if anyone else has tips to share, thank you!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard