Forum Discussion

Phishdawg's avatar
Phishdawg
Brass Contributor
Sep 07, 2023
Solved

Tables Called in Flow Not Found

I have an Excel workbook that is moved, by flow, from an Outlook in-box to a SharePoint library.

The workbook has four sheets.

I created four scripts, one for each sheet in the workbook.

Each script ends with -  
   // Create a table with format on range A1:AP25 on selectedSheet
   let Continuous_Tbl = workbook.addTable
      (selectedSheet.getRange ("A1:AP25"), true);
  Continuous_Tbl.setPredefinedTableStyle
       ("TableStyleLight8");

I created a flow that uses four 'Run Script' actions to initiate the four script codes shown above.

This all works; The scripts run, the data is transformed, and the tables created. 

I have another flow with a trigger of - 'When a file is created (properties only)', and four 'Run Scripts' actions that initiate the scripts.

Also, in the flow are four 'List rows present in table', and four 'Apply to each' actions, each with a 'Create item' associated with a SharePoint list.

I am getting and error at the first (and probably all) 'List rows present in table' action stating the table is 'not found'.

Have tried a four 'Compose' action, with the name of the table(s) called out in each script, as well as just Table1, Table2, and so on. in the 'List rows present in table', I keep getting the error.

What am I missing?

  • Phishdawg 

    The error you are encountering in Power Automate (formerly known as Microsoft Flow) indicating that the table is "not found" typically occurs when the table name referenced in the 'List rows present in table' action doesn't match the actual table name in the Excel workbook. To resolve this issue, follow these steps:

    1. Check Table Names in Excel:
      • Open the Excel workbook that your script is modifying.
      • Make sure that the tables created by your scripts indeed have the names you expect (e.g., "Table1," "Table2," etc.).
    2. Explicitly Specify Table Names:
      • In your script, explicitly set the names of the tables you create using the addTable method. For example, you can modify your script like this:
    let Continuous_Tbl = workbook.addTable(selectedSheet.getRange("A1:AP25"), true);
    Continuous_Tbl.setName("Table1"); // Specify the table name explicitly
    Continuous_Tbl.setPredefinedTableStyle("TableStyleLight8");

    Make sure that the table names in your script match the actual table names in Excel.

    1. Use the Correct Table Names in Power Automate:
      • In your Power Automate flow, when using the 'List rows present in table' action, make sure you are providing the correct table name that matches the one specified in your script. If you explicitly named the table in your script (as shown in the previous step), use that name. If you didn't specify a name, use the default "Table1," "Table2," etc.
    2. Check SharePoint List Connections:
      • Ensure that your SharePoint list connections are correctly configured and that you are working with the right list.
    3. Test Incrementally:
      • To identify the specific step where the issue is occurring, try running your flow incrementally. For example, start by running just one 'Run Script' action and see if the table is created and named correctly. Then, add the 'List rows present in table' action and test it separately.
    4. Flow Debugging:
      • Use the built-in debugging capabilities of Power Automate to inspect variables and outputs at each step of your flow to identify where the issue is occurring.
    5. Flow Logging:
      • Add logging actions (e.g., 'Compose' actions with informative messages) at key points in your flow to help diagnose issues. This can provide more visibility into the flow's behavior.

    By carefully checking the table names in your Excel workbook and ensuring that they match the names referenced in your script and Power Automate, you should be able to resolve the "not found" error and successfully list rows present in the tables in your flow.

    My knowledge of this topic is limited, but I entered your question in various AI. The text and the steps are the result of various AI's put together.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

5 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Phishdawg 

    The error you are encountering in Power Automate (formerly known as Microsoft Flow) indicating that the table is "not found" typically occurs when the table name referenced in the 'List rows present in table' action doesn't match the actual table name in the Excel workbook. To resolve this issue, follow these steps:

    1. Check Table Names in Excel:
      • Open the Excel workbook that your script is modifying.
      • Make sure that the tables created by your scripts indeed have the names you expect (e.g., "Table1," "Table2," etc.).
    2. Explicitly Specify Table Names:
      • In your script, explicitly set the names of the tables you create using the addTable method. For example, you can modify your script like this:
    let Continuous_Tbl = workbook.addTable(selectedSheet.getRange("A1:AP25"), true);
    Continuous_Tbl.setName("Table1"); // Specify the table name explicitly
    Continuous_Tbl.setPredefinedTableStyle("TableStyleLight8");

    Make sure that the table names in your script match the actual table names in Excel.

    1. Use the Correct Table Names in Power Automate:
      • In your Power Automate flow, when using the 'List rows present in table' action, make sure you are providing the correct table name that matches the one specified in your script. If you explicitly named the table in your script (as shown in the previous step), use that name. If you didn't specify a name, use the default "Table1," "Table2," etc.
    2. Check SharePoint List Connections:
      • Ensure that your SharePoint list connections are correctly configured and that you are working with the right list.
    3. Test Incrementally:
      • To identify the specific step where the issue is occurring, try running your flow incrementally. For example, start by running just one 'Run Script' action and see if the table is created and named correctly. Then, add the 'List rows present in table' action and test it separately.
    4. Flow Debugging:
      • Use the built-in debugging capabilities of Power Automate to inspect variables and outputs at each step of your flow to identify where the issue is occurring.
    5. Flow Logging:
      • Add logging actions (e.g., 'Compose' actions with informative messages) at key points in your flow to help diagnose issues. This can provide more visibility into the flow's behavior.

    By carefully checking the table names in your Excel workbook and ensuring that they match the names referenced in your script and Power Automate, you should be able to resolve the "not found" error and successfully list rows present in the tables in your flow.

    My knowledge of this topic is limited, but I entered your question in various AI. The text and the steps are the result of various AI's put together.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    • Phishdawg's avatar
      Phishdawg
      Brass Contributor

      NikolinoDE 
      Here is an example. The flow errors out on the first 'List rows present in a table', saying there is no 'Table1'. 

      Yet, you can clearly see in the Excel workbook the script created a 'Table1'.

       

      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        Phishdawg 

        As for the Power Automate. Flow actually gets table not by name, but it's internal ID. If you create flow with existing table, you simply add its name, flow converts internally to ID and work with it. Next time you run query, you create the table with the same name, but each new table have new ID independently of name. Flow tries to find that ID and files - you re-created the table and old ID doesn't exists.

        The workaround could be as following.

        After running the script we initialize string variable and Get Tables on the file

        Get Tables returns collection (array) with each table data. We are interesting in ID and Name.

        In Apply To Each we set ID on above variable for the table with given name

        On the next step wit add this variable from dynamic content as table name

        With that all works

         

    • Phishdawg's avatar
      Phishdawg
      Brass Contributor
      As provided in my initial post, my script has the below code at the end, where I am specifically requiring the script to create the table name.

      Is there anything wrong with the code provided below?

      Is this code written so that it will create a table named 'Continuous_Tbl'?

      The flow runs through all of the 'Run Script' actions without issue.

      However, when it gets to the first 'Create item' action the flow errors, stating 'table not found', whether the table is named 'Table1' or 'Continuous_Tbl'.

      When I use my 'Compose' action to call specifically 'Table1' in the 'List rows present in a table' I still get an error that the table is not found.

      I have visually verified that the script is creating tables named 'Table1', 'Table2'...etc, and not 'Continuous_Tbl'. Why would this be if the script language is correct, if so?

      // Create a table with format on range A1:AP25 on selectedSheet
      let Continuous_Tbl = workbook.addTable
      (selectedSheet.getRange ("A1:AP25"), true);
      Continuous_Tbl.setPredefinedTableStyle
      ("TableStyleLight8");
      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        Phishdawg 

        In Office Script you need to set table name, something like

        function main(workbook: ExcelScript.Workbook) {
        
            const sheet = workbook
                .getFirstWorksheet()
            const ref = "A1:B3"
        
            const range = 
                sheet.getRange(ref)
        
            if (range.getTables().length==0) {
                const tbl = sheet
                    .addTable(ref, true)
                tbl.setName("Continious_Tbl")
            }
        }    
        
        

        As a comment, Power Automate has now idea which sheet you selected and what is the active sheet. You need to define it by name or index.

Resources