cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kongol
Advocate I
Advocate I

Excel Run Script Flow Doesn't Change Tab Color

Hello!

 

Whenever I run my office script manually, the tab colors that I set do change.

 

However, whenever the script runs on behalf of my Power Automate flow, the tab color is unchanged despite the script returning a successful execution. Does anyone know why this could be? When calling for the worksheets to change the tab color, I'm not using "getActiveWorksheet", I am using the actual names of the sheets to modify the tab color. 

 

I know this issue exists with Power Automate and "getActiveWorksheet", but the worksheet names are hardcoded in the script. The color change just gets ignored. Thanks in advance for any help you can provide!

19 REPLIES 19

Hi @Kongol ,

 

The following script worked for me:

function main(workbook: ExcelScript.Workbook) {
  workbook.getWorksheet("Sheet1").setTabColor("yellow");
}

 

I triggered a this script from a Power Automate flow and it indeed changed the tab color to yellow.

 

Can you try making some different changes (like set range value, etc.) with the script to the same workbook and see if that works?

All other processes contained within that script are functioning properly. Here is the relevant code from my script:

 

  // Convoluted call to current month's sheet
  var d = new Date();
  const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  var month = monthNames[d.getMonth()];
  var year = String(new Date().getFullYear());
  var sheet = workbook.addWorksheet(month+year);

  // Convoluted call to last month's sheet
  var lastMonth = monthNames[d.getMonth()-1];
  if (month == "Jan"){
    var lastYear = String(new Date().getFullYear()-1);
  }
  else{
    var lastYear = String(new Date().getFullYear());
  }
  var lastSheet = workbook.getWorksheet(lastMonth+lastYear);

  // Sheet & Table formatting
  var lastTable = lastSheet.getTable(lastMonth+"_"+lastYear);
  var newHead = lastTable.getHeaderRowRange();
  sheet.getRange("A1:M1").setValues(newHead.getTexts());
  sheet.setTabColor("00FFFF");
  sheet.setPosition(0);
  lastSheet.setTabColor("D3D3D3");

 

 

Everything else including changing the position of the sheet in the workbook, setting the values of the header range within the sheet, & other modified properties irrelevant to this issue also function properly. Feel free to request more information or a demonstration of what I am experiencing and I will be more than happy to oblige!  Thank you for helping me out and apologies for the late response.

Thanks for sharing the details. That is very helpful! Now I am able to repro the problem as well.

Sorry this might be a bug on our side. We will need to take some time to investigate and get back to you with an update as soon as possible.

Apologies for not sharing the details sooner, still new to this environment and communicating my problems in a way that is concise while also providing enough elaboration to get everyone on the same page as me!

 

I really appreciate your effort to resolve this problem and I'm honestly a bit impressed in myself if I've found a bug in a system that a bunch of brainiacs utilize on a daily basis!! If there's another way I can accomplish my goal as a workaround that would be more than acceptable as well. Have a great day!

@Kongol, just wanted to give you an update that we're still investigating the root cause of this problem. Thanks for your patience!

Absolutely no problem at all! I’m still stoked that I even managed to be the first to find this bug. Every day that you guys don’t have a solution I take as a compliment knowing it is a complex issue. I live for stuff like this!

 

Please take all the time that you need, I’m sure you guys have much more urgent matters to attend to. I just appreciate your continuous effort to follow up on my problem!! Love this community.

Hi @Kongol, just wanted to confirm some additional points with you:

 

 1. For this bug, did you open the workbook in the browser, then run the Power Automate script, and then look at the workbook from the first step to see that the color didn't change? Does it matter whether the workbook is open in the browser or not?

2. Will refreshing the workbook in the browser make the color change?

@GeoffRen ,

 

I really appreciate your response!!! This solved my problem in a way however is more of a workaround than a fix. Turns out, if I have the workbook closed when I run the flow, upon opening the workbook the tab color is changed. However, If I have the workbook open when I run the flow, the tab color will not change. Refreshing/closing and reopening does not change the color either. I waited a couple days too and still no luck, never updated the tab color. 

 

My only concern is other employees having the workbook open when the script runs, resulting in the tab color not changing. Otherwise, having the workbook closed seems to accomplish what I'm looking for! I really appreciate your guys' help with this. Sorry for the late reply, last week was a mess!

@Kongol,

 

Thanks for your patience!

 

Now we have identified the root cause of this problem. The ETA for the fix would be the next quarter for the earliest.

 

Thanks again for reporting this good bug!

@Yutao,

 

Thank y'all for the continued effort to resolve this. This experience is one I will not forget and I look forward to further developing myself professionally with more intricate Power Automate flows. 

 

Eagerly will await confirmation that this has been fixed. Can't thank you enough!

Has this bug been fixed?  I am running into something similar.  When I run my script manually (through excel online) everything works as it should.  However, when the script runs via a flow, it doesn't actually do the work.  (even though it says everything was completed successfully.  

I have tested this every way I can.  When the sheet is open, the flow runs all good.  When the script is running through the sheet, all is good it works as it should.  When the sheet is closed, the flow runs, noting.  

@KGuthrie-NF - could you share a little more about the issue you are running into? Is it also about the tab color or something else?

 

Regarding this particular tab color issue @Kongol originally reported, I'm happy to share an update that our team is working on it right now. Apologize this has been a while. But hope you can understand the challenges we've had with a giant queue of feature requests and bug fixes. Thank you again for all the patience!

My issue does not deal with tab color.  It is similar.  My script should be copying rows from one tab to another based on a new submission on a form.  

The process is:  A new submission on a form tracks the response on Form 1 on an excel sheet.  This also triggers a flow to copy the needed user responses to another sheet on the same excel sheet.  As I mentioned before the script works.  When I run it within the sheet, the row copies.  When I have the sheet open and submit a new form, the script runs and copies the row.  However, when the sheet is closed, I submit a new form, the flow says the script ran successfully, but when I open the sheet, the row did not copy. 

Not sure if it matters, but everything resides on the same SharePoint site.

@KGuthrie-NF - What you described sounds like a very typical scenario that Office Scripts should support but we may be missing something here. Would you mind sharing your script? At the same time, you can also try using console.log(...) to output some debugging info (e.g., the steps in your script execution, the copied content, etc.), and see if the script indeed works as expected. You can find the output message from your flow's run history in Power Automate.

 

In your first message, you mentioned "When I run my script manually (through excel online) everything works as it should. However, when the script runs via a flow, it doesn't actually do the work. (even though it says everything was completed successfully."  It sounded to me that your script has never worked in Power Automate. But in your second post, it sounded to me the script can still work in Power Automate flow but the target workbook has to be open during the time the flow runs. Just wanted to confirm the exact behavior...

 

Thanks!

Below is the code in the script.  

function main(workbook: ExcelScript.Workbook)
{
  let Form1 = workbook.getWorksheet("Form1");
  let FRWB = workbook.getWorksheet("Facilities Request WB");

  //Get Date from Form1
  FRWB.getRange("B:B").copyFrom(Form1.getRange("B:B"), ExcelScript.RangeCopyType.values);
  console.log("Date Range Copied");

  //Get Submittion Email from Form1
  FRWB.getRange("C:C").copyFrom(Form1.getRange("D:D"));
  console.log("Submission Email Range Copied");

  //Get Requester from Form1
  FRWB.getRange("D:D").copyFrom(Form1.getRange("F:F"));
  console.log("Requester Range Copied");

  //Get Phone Ext from Form1
  FRWB.getRange("E:E").copyFrom(Form1.getRange("G:G"));
  console.log("Phone/Ext. Range Copied");

  //Get Issue from Form1
  FRWB.getRange("F:F").copyFrom(Form1.getRange("H:H"));
  console.log("Issue Range Copied");
 
  //Get Issue Location from Form1
  FRWB.getRange("G:G").copyFrom(Form1.getRange("I:I"));
  console.log("Issue Location Range Copied");

  //Get Area of Issue from Form1
  FRWB.getRange("H:H").copyFrom(Form1.getRange("K:K"));
  console.log("Area of Issue Range Copied");

  //Get Attachment from Form1
  FRWB.getRange("I:I").copyFrom(Form1.getRange("J:J"));
  console.log("Attachment Range Copied");

  //Set emailed and complete to NO
  let lastEmail = FRWB.getUsedRange()
  //console.log(lastEmail.getAddress());
  let sent = FRWB.getRange("K" + lastEmail.getRowCount())
  console.log(sent.getAddress())
  sent.setValue("No");
  console.log("Emailed indicator set in cell " + sent.getAddress());

  let done = FRWB.getRange("A" + lastEmail.getRowCount())
  //console.log(mail.getAddress())
  done.setValue("No");
  console.log("Request done indicator set in cell " + done.getAddress());

}

 

The flow works,  I have run through it multiple times.  The only part that doesn't work is the update script. The log of the flow says the script was successful.  

So were you able to see those console logs output from your script and see how the code was executed? You can expand the "Run script" action from a run history and look into the body. For example:

Yutao_0-1648773692444.png

 

The body contains this:

 

{
  "logs": [
    "[2022-03-28T16:19:19.9580Z] Date Range Copied",
    "[2022-03-28T16:19:20.0370Z] Submission Email Range Copied",
    "[2022-03-28T16:19:20.1300Z] Requester Range Copied",
    "[2022-03-28T16:19:20.2240Z] Phone/Ext. Range Copied",
    "[2022-03-28T16:19:20.3020Z] Issue Range Copied",
    "[2022-03-28T16:19:20.3960Z] Issue Location Range Copied",
    "[2022-03-28T16:19:20.4590Z] Area of Issue Range Copied",
    "[2022-03-28T16:19:20.5370Z] Attachment Range Copied",
    "[2022-03-28T16:19:20.7550Z] Emailed indicator set in cell 'Facilities Request WB'!K17",
    "[2022-03-28T16:19:20.9120Z] Request done indicator set in cell 'Facilities Request WB'!A17"
  ]
}

  Row 17 is the last row of the current sheet. 

@KGuthrie-NF - I tried your script with a test workbook and test flow but still couldn't reproduce the issue. If you would like, please feel free to contact me through private message and we can further investigate your case.

Hello @Kongol, I just heard back from my teammate that the tab color issue has been fixed now! I also verified it myself and my script indeed was able to update the tab color correctly no matter the workbook was open or closed. Please give it a try when you get time and let me know if there are any other issues. Thanks again for your patience!

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (878)