Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Office Script Error: "Script not found. It may have been unshared or deleted"

 I am working on  a Power Automate Run Script process which takes a number as a parameter and outputs a JSON object. I am having an error of "Script not found. It may have been unshared or deleted" whenever someone other than me is running the flow. The flow is triggered from PowerApps.


Here are the things I have done so far:

1. Made sure that workbook is shared and has edit (the person is even the owner now of the folder and the file itself)

2. Made sure that the script is shared enabled also

3. I even shared the power automate ownership to the person

4. Tested with other person with same permission configuration

5. Tested to run the script by its own both by me and that person and it's running okay except if the person run it through power automate



Community Support
Community Support

Hi @rmprecioso,


What's the script do? Do you mind sharing the script?

How about trying to delete the script then recreate a new one to test?


Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Frequent Visitor

hi @v-litu-msft 

What the script does is to create an array of object, shuffle it, and get the top items in the list. 

I tried recreating it as well.

Here is the script:

function main(workbook: ExcelScript.Workbook, top: number = 1😞 Result {
    let selectedSheet = workbook.getWorksheet("Participant");


    let selectedRange = selectedSheet.getRange("A1").getSurroundingRegion().getValues();


    let pool: Winner[] = [];


    for (let i = 1; i < selectedRange.length; i++) {
        let range = selectedRange[i];
        let upinO = range[3].toString();
            upin: upinO.substring(0,upinO.indexOf('@')),
            name: range[4].toString(),
            department: range[5].toString(),
            eligibility: range[7].toString(),


    var shuffledPool = shuffle(pool.filter(isEligible));


    console.log(shuffledPool.slice(0, top));


    let result = {
      eligibleCount: shuffledPool.length,
      winners :shuffledPool.slice(0, top)
    return result;




interface Result{
  winners: Winner[];
  eligibleCount: number;


interface Winner {
    name: string;
    upin: string;
    department: string;
    eligibility: string;


function isEligible(element, index, array) {
  return (element.eligibility == 'ok');


function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;


  // While there remain elements to shuffle...
  while (0 !== currentIndex) {


    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;


    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;


  return array;

Hi @rmprecioso ,


Unfortunately, at this moment, the Run script action can only access and execute the scripts created by yourself but not shared scripts.


Therefore, when you're sharing a flow with other people, you'll need to also share the original connection (the one created under your name) embedded in that flow. The original connection can make sure the action will run on-behalf-of you so it can have access to your script.


This is the default sharing behavior in Power Automate so presumably it should work for you. But can you please double check if the embedded connection is still pointing to your account?


Screenshot - 12_14_2020 , 10_32_59 AM.png



Frequent Visitor

Hi Yutao,
I added the other user as co-owner to the flow, and yet the flow is failing at Run Script stage. Any suggestions?

Resolver I
Resolver I

Hey Neha, 
Were you able to find the fail reason? I'm facing the same issue now. 


@Serbay , @rmprecioso , @Neha2904


Please see if the steps below can solve the problem:


1. On the details page of the flow, click the "Edit" button next to "Run only users":


Screenshot - 2_26_2021 , 9_04_49 AM.png


2. On the "Manage run-only permissions" panel, make sure to select "Use this connection (...)" from the "Connection Used" dropdown list.


Screenshot - 2_26_2021 , 9_03_54 AM.png



3. Save the settings


4. Ask another user to try it again.


These settings will make sure the flow runs on-behalf-of the original owner of the flow.


Hope this helps!



Resolver I
Resolver I

Hi, Yutao 
Thanks a lot for your response! Definitely, this solution will be helpful on some of my flows. But Unfortunately, there is no option as "Run only users for me" since I use the trigger as "PowerApps". I guess this is valid only with some of the triggers.
Do you have any idea how can we make sure a flow which has a PowerApps trigger will run on the behalf of the owner, not the user?

Thanks a lot!


Hey @Serbay ,


Yes indeed it seems the "Run-only" settings only supports very few triggers (the manual button trigger being one).

I did a bit experiments and figured out a solution that worked for me -


* Firstly, you'll need to create all your flows and PowerApps apps within a "Solution". You can create a new solution from "Solutions/New solution":



* Within this new solution, create a button-triggered flow that runs Office Scripts. Let's call it "Child flow". Please note this flow requires to have a last action to respond to a PowerApp or flow.

Child flow.png


* Configure this child flow with run-only users settings as described in my previous response. Make sure to choose "Use this connection ...".


* Within the same solution, create another flow with the PowerApps trigger. This flow will be triggered by your PowerApps app. In this flow, add a step to run the child flow you've just created above:

Parent flow.png


* Within the same solution, create your PowerApps app. Configure your PowerApps button to run the second flow (the parent flow).


* Now share the PowerApps app with another user, ask them to try it out, and see if the Run script action in the child flow can work properly.


Hope this can also work for you!



Resolver I
Resolver I

Hi, Yutao 
I really appreciate your help and responses. I have a single obstacle now, How can we pass the output of one of the actions from PowerApps triggered flow into child flow? I need to use the body of the parse JSON action in child flow.





Best Regards,

Hey @Serbay -


Please see if this works:


* In the child flow, add a text input (or whatever input type you need) to the manual trigger. Let's call it "Input". And pass that input value to the consuming actions after it. For example, here I'm passing it directly to the Run script action:



* In the parent flow (the PowerApps triggered flow), a new argument named "Input" to run the Child Flow will show up.





Regular Visitor

After Support call from MS support team, I found correct process to add both flows accurately.


1. Create a Child flow with Manual trigger with input -> add initialize variable and set value as input from manual trigger -> Add respond to a PowerApp action -> save the child flow

2. Create a Parent flow using PowerApp trigger -> Add run child flow action -> set value from Powerapp form -> Add respond to a PowerApp action and get input from Run Child flow action-> save the parent flow.

3. Add Parent flow to the Powerapps button.

4. Test your both flow by trying to hit PowerApp button in PowerApps form. 

5. If step 4 runs without any error, go for additional action sets in the child flow. Please make sure to add new connection reference on actions and select connection from the "Run only users " link button 





Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,589)