cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Power_Automater
Helper III
Helper III

How to get the name of a List?

I would like to include the name of an MS List in the subject of an email so that the recipient knows which list this email is about. I am using a recurrence flow to compile the daily changes that have occurred in a list and then sending out emails in Apply to Each to the various people assigned to those changes.

 

I thought since I manually specify the List in Get Items that I could simply initialize a variable with Name from this but when trying the variable is automatically put inside another Apply to Each. Since the flow only concerns one List I'm sure this is not the right way. How do I go about this?

 

Power_Automater_0-1644286261658.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @Power_Automater,

 

You could reuse what you have selected in the Get Items. This is stored as one of the input parameters. However, the challenge is that it is stored with the GUID of the list and not the actually name. You can workaround this by using a Send an HTTP request action to retrieve the title.

 

Below is an example of that approach.

The Send an HTTP request actions uses a GET method to retrieve the properties of your selected list in the Get Items. In this example I am only returning the Title. Which will be stored in a string variable in the action after that.

 

_api/web/lists(guid'@{actions('Get_Items')['inputs']['parameters']['table']}')?$select=Title

 

inputparameters_table.png

View solution in original post

4 REPLIES 4
Expiscornovus
Super User
Super User

Hi @Power_Automater,

 

You could reuse what you have selected in the Get Items. This is stored as one of the input parameters. However, the challenge is that it is stored with the GUID of the list and not the actually name. You can workaround this by using a Send an HTTP request action to retrieve the title.

 

Below is an example of that approach.

The Send an HTTP request actions uses a GET method to retrieve the properties of your selected list in the Get Items. In this example I am only returning the Title. Which will be stored in a string variable in the action after that.

 

_api/web/lists(guid'@{actions('Get_Items')['inputs']['parameters']['table']}')?$select=Title

 

inputparameters_table.png

Thank you @Expiscornovus I will give this a try later today and let you know how I go. Is there really no built in action in Automate/Flow to get the name/title of a list? It seems strange that it is possible to get all of the list data in each row and column but not the name of the list itself.

Expiscornovus
Super User
Super User

Hi @Power_Automater,

 

As far as I am aware there are only two actions which interact with lists and both of them retrieve all items and don't have a filter capability. That's why I used the approach with the built in Send an HTTP request to SharePoint action.

 

lists_action.png

 

Btw, another approach would be to extract it from one of the fields in the output of your get items. This means you don't have to add an additional action. 

 

Below is an example of that second approach.

This expression only works if the get items action returns at least one item. It gets the path property and splits on / to retrieve the list name of the value.

 

 

 

split(outputs('Get_items')['body/value'][0]['{path}'], '/')[1]

 

 

 

listname_outputs_fullpath.png

 

Ok I tried this and it works great so thank you. I am just wondering though if it is possible to get the list name via a Calculated Column in Lists, since then it would automatically be accessible after the Get Items action. I've tried to search for the formula but haven't found anything.

Or I suppose I could add it manually and then use something below to retrieve it from a filter array (where field_3 is the name of the column with the list name in it):
body('Filter_array_2')?[0]?['field_3']

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (4,880)