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
Yutao
Employee
Employee

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.

Yutao
Employee
Employee

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!

Yutao
Employee
Employee

@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!

Yutao
Employee
Employee

@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!

KGuthrie-NF
Helper I
Helper I

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.  

Yutao
Employee
Employee

@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.

Yutao
Employee
Employee

@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!

KGuthrie-NF
Helper I
Helper I

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.  

Yutao
Employee
Employee

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

 

KGuthrie-NF
Helper I
Helper I

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. 

Yutao
Employee
Employee

@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.

Yutao
Employee
Employee

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

Exclusive LIVE Community Event: Power Apps Copilot Coffee Chat with Copilot Studio Product Team

It's time for the SECOND Power Apps Copilot Coffee Chat featuring the Copilot Studio product team, which will be held LIVE on April 3, 2024 at 9:30 AM Pacific Daylight Time (PDT).     This is an incredible opportunity to connect with members of the Copilot Studio product team and ask them anything about Copilot Studio. We'll share our special guests with you shortly--but we want to encourage to mark your calendars now because you will not want to miss the conversation.   This live event will give you the unique opportunity to learn more about Copilot Studio plans, where we’ll focus, and get insight into upcoming features. We’re looking forward to hearing from the community, so bring your questions!   TO GET ACCESS TO THIS EXCLUSIVE AMA: Kudo this post to reserve your spot! Reserve your spot now by kudoing this post.  Reservations will be prioritized on when your kudo for the post comes through, so don't wait! Click that "kudo button" today.   Invitations will be sent on April 2nd.Users posting Kudos after April 2nd at 9AM PDT may not receive an invitation but will be able to view the session online after conclusion of the event. Give your "kudo" today and mark your calendars for April 3, 2024 at 9:30 AM PDT and join us for an engaging and informative session!

Tuesday Tip: Unlocking Community Achievements and Earning Badges

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!     THIS WEEK'S TIP: Unlocking Achievements and Earning BadgesAcross the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. These badges each signify a different achievement--and all of those achievements are available to any Community member! If you're a seasoned pro or just getting started, you too can earn badges for the great work you do. Check out some details on Community badges below--and find out more in the detailed link at the end of the article!       A Diverse Range of Badges to Collect The badges you can earn in the Community cover a wide array of activities, including: Kudos Received: Acknowledges the number of times a user’s post has been appreciated with a “Kudo.”Kudos Given: Highlights the user’s generosity in recognizing others’ contributions.Topics Created: Tracks the number of discussions initiated by a user.Solutions Provided: Celebrates the instances where a user’s response is marked as the correct solution.Reply: Counts the number of times a user has engaged with community discussions.Blog Contributor: Honors those who contribute valuable content and are invited to write for the community blog.       A Community Evolving Together Badges are not only a great way to recognize outstanding contributions of our amazing Community members--they are also a way to continue fostering a collaborative and supportive environment. As you continue to share your knowledge and assist each other these badges serve as a visual representation of your valuable contributions.   Find out more about badges in these Community Support pages in each Community: All About Community Badges - Power Apps CommunityAll About Community Badges - Power Automate CommunityAll About Community Badges - Copilot Studio CommunityAll About Community Badges - Power Pages Community

Tuesday Tips: Powering Up Your Community Profile

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   This Week's Tip: Power Up Your Profile!  🚀 It's where every Community member gets their start, and it's essential that you keep it updated! Your Community User Profile is how you're able to get messages, post solutions, ask questions--and as you rank up, it's where your badges will appear and how you'll be known when you start blogging in the Community Blog. Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile.     Password Puzzles? No Problem! Find out how to sync your Azure AD password with your community account, ensuring a seamless sign-in. No separate passwords to remember! Job Jumps & Email Swaps Changed jobs? Got a new email? Fear not! You'll find out how to link your shiny new email to your existing community account, keeping your contributions and connections intact. Username Uncertainties Unraveled Picking the perfect username is crucial--and sometimes the original choice you signed up with doesn't fit as well as you may have thought. There's a quick way to request an update here--but remember, your username is your community identity, so choose wisely. "Need Admin Approval" Warning Window? If you see this error message while using the community, don't worry. A simple process will help you get where you need to go. If you still need assistance, find out how to contact your Community Support team. Whatever you're looking for, when it comes to your profile, the Community Account Support Knowledge Base article is your treasure trove of tips as you navigate the nuances of your Community Profile. It’s the ultimate resource for keeping your digital identity in tip-top shape while engaging with the Power Platform Community. So, dive in and power up your profile today!  💪🚀   Community Account Support | Power Apps Community Account Support | Power AutomateCommunity Account Support | Copilot Studio  Community Account Support | Power Pages

Super User of the Month | Chris Piasecki

In our 2nd installment of this new ongoing feature in the Community, we're thrilled to announce that Chris Piasecki is our Super User of the Month for March 2024. If you've been in the Community for a while, we're sure you've seen a comment or marked one of Chris' helpful tips as a solution--he's been a Super User for SEVEN consecutive seasons!   Since authoring his first reply in April 2020 to his most recent achievement organizing the Canadian Power Platform Summit this month, Chris has helped countless Community members with his insights and expertise. In addition to being a Super User, Chris is also a User Group leader, Microsoft MVP, and a featured speaker at the Microsoft Power Platform Conference. His contributions to the new SUIT program, along with his joyous personality and willingness to jump in and help so many members has made Chris a fixture in the Power Platform Community.   When Chris isn't authoring solutions or organizing events, he's actively leading Piasecki Consulting, specializing in solution architecture, integration, DevOps, and more--helping clients discover how to strategize and implement Microsoft's technology platforms. We are grateful for Chris' insightful help in the Community and look forward to even more amazing milestones as he continues to assist so many with his great tips, solutions--always with a smile and a great sense of humor.You can find Chris in the Community and on LinkedIn. Thanks for being such a SUPER user, Chris! 💪 🌠  

Tuesday Tips: Community Ranks and YOU

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!This Week: Community Ranks--Moving from "Member" to "Community Champion"   Have you ever wondered how your fellow community members ascend the ranks within our community? What sets apart an Advocate from a Helper, or a Solution Sage from a Community Champion? In today’s #TuesdayTip, we’re unveiling the secrets and sharing tips to help YOU elevate your ranking—and why it matters to our vibrant communities. Community ranks serve as a window into a member’s role and activity. They celebrate your accomplishments and reveal whether someone has been actively contributing and assisting others. For instance, a Super User is someone who has been exceptionally helpful and engaged. Some ranks even come with special permissions, especially those related to community management. As you actively participate—whether by creating new topics, providing solutions, or earning kudos—your rank can climb. Each time you achieve a new rank, you’ll receive an email notification. Look out for the icon and rank name displayed next to your username—it’s a badge of honor! Fun fact: Your Community Engagement Team keeps an eye on these ranks, recognizing the most passionate and active community members. So shine brightly with valuable content, and you might just earn well-deserved recognition! Where can you see someone’s rank? When viewing a post, you’ll find a member’s rank to the left of their name.Click on a username to explore their profile, where their rank is prominently displayed. What about the ranks themselves? New members start as New Members, progressing to Regular Visitors, and then Frequent Visitors.Beyond that, we have a categorized system: Kudo Ranks: Earned through kudos (teal icons).Post Ranks: Based on your posts (purple icons).Solution Ranks: Reflecting your solutions (green icons).Combo Ranks: These orange icons combine kudos, solutions, and posts. The top ranks have unique names, making your journey even more exciting! So dive in, collect those kudos, share solutions, and let’s see how high you can rank!  🌟 🚀   Check out the Using the Community boards in each of the communities for more helpful information!  Power Apps, Power Automate, Copilot Studio & Power Pages

Find Out What Makes Super Users So Super

We know many of you visit the Power Platform Communities to ask questions and receive answers. But do you know that many of our best answers and solutions come from Community members who are super active, helping anyone who needs a little help getting unstuck with Business Applications products? We call these dedicated Community members Super Users because they are the real heroes in the Community, willing to jump in whenever they can to help! Maybe you've encountered them yourself and they've solved some of your biggest questions. Have you ever wondered, "Why?"We interviewed several of our Super Users to understand what drives them to help in the Community--and discover the difference it has made in their lives as well! Take a look in our gallery today: What Motivates a Super User? - Power Platform Community (microsoft.com)

Users online (5,837)