Skip to main content

Notifications

Convert SharePoint ListId/GUID to URL using Power Automate

This simple 3 step flow will convert an easily found listId / GUID into a usable URL.

01 initialise the URL variable.jpg

 

02 Get lists.jpg

 

03 Apply to each.jpg

 

I did not make a cookbook because I don't wish to upload ZIPs of my flows as they contain information.

 

The reason I needed it is that there's no (programmatical) simple way to reliably get the URL of a list, since the list name may have been changed since it was created. This is almost 100% true for all of my lists, since when I create them I make them with a one word, URL friendly, name, to avoid the %20 encoding effect and keep things tidy.

 

I use this in my master "list of lists" which then catalogues all the lists that I have on every site. That will be added shortly.

 

I think you should be OK to skip steps 6, 7, and 8, and just use the reference schema code that I've put at the end, but it's your lookout there.

 

  1. Create a 'Instant' flow, or whatever you need to do.
  2. Create an 'Initialize variable' action with a 'Type' of "STRING" and name it " urlVAR " (or whatever you do for naming)
    01 initialise the URL variable.jpg
  3. Create a SharePoint 'Get_lists' action for the site in question.
    02 Get lists.jpg
  4. Create an 'Apply to each' Control action for the value reported from the 'Get_lists'. The tooltip should read:
    outputs('Get_lists')?['body/value']​​​
  5. In the 'Apply to each' action create a SharePoint 'Send an HTTP request to SharePoint' action for the site in question with the following entries, you can leave the 'Body' value blank:
    0301 Apply to each - HTTP request.jpg
    - 'Site Address' - Select the same site as in 'Get lists'
    - 'Method' - Select "Get"
    - 'Uri' - Set this to
    _api/web/lists(guid'[NAME]')​​
    ... where " [NAME] " is the "Name" dynamic content from the 'Get lists' which should have the tooltip text of:
    items('Apply_to_each')?['Name']​​
    - 'Headers' - The output should be JSON, but if we put the following in here it will ensure that:
    {
    "Accept": "application/json;odata=nometadata"
    }​​
  6. Create a 'Compose' action, and in the 'Inputs' field, select the 'body' from the HTTP request (Flow Step 3).
    compose.jpg
  7. Run a test of the flow.
    This will give us the body JSON that we need to perform a parse JSON in the final build of the flow.
    Copy the 'Output' content from this 'Compose' action. 
  8. After the test has run, go back and edit the flow, and delete the 'Compose' action.
  9. After the HTTP request create a 'Parse JSON' action, then:
    0302 Apply to each - Parse JSON.jpg
    - Set the 'Content' field to the body Dynamic content from the HTTP request, it should give something like the following tooltip:
    outputs('Send_an_HTTP_request_to_SharePoint')?['body']​​
    - Paste the copied data from the 'body' run into the 'Schema' field.
  10. Finally create a 'Set variable' action to get the URL, enter the site URL, followed by /Lists/, then we'll add an expression, it should look like this:
    0303 Apply to each - Set Variable.jpg
    The 'Value' field should be:
    [SITE URL]/Lists/[EXPRESSION]​
    Where [SITE URL] is your Site URL, and [EXPRESSION] is:
    substring(body('Parse_JSON')?['ListItemEntityTypeFullName'],8,add(length (body('Parse_JSON')?['ListItemEntityTypeFullName']),-16))​

 

 

Most of the work is done in the expression in the Set variable' action, which is basically trimming the site "name" out of the extracted information. I used  this solution to help with that:

https://powerusers.microsoft.com/t5/Building-Flows/MS-Flow-Variable-Remove-Last-Character-In-a-String/td-p/294234

Hope that this can help folks out elsewhere.

If someone needs me to put this in the form of a question, and then answer it myself, I'm more than happy to, but I'm just not uploading my information in a zip format.

 

------------

Reference

 

You should be OK to skip the steps mentioned, as I believe that this code will work anywhere:

 

 

 

 

{
 "type": "object",
 "properties": {
 "AllowContentTypes": {
 "type": "boolean"
 },
 "BaseTemplate": {
 "type": "integer"
 },
 "BaseType": {
 "type": "integer"
 },
 "ContentTypesEnabled": {
 "type": "boolean"
 },
 "CrawlNonDefaultViews": {
 "type": "boolean"
 },
 "Created": {
 "type": "string"
 },
 "CurrentChangeToken": {
 "type": "object",
 "properties": {
 "StringValue": {
 "type": "string"
 }
 }
 },
 "DefaultContentApprovalWorkflowId": {
 "type": "string"
 },
 "DefaultItemOpenUseListSetting": {
 "type": "boolean"
 },
 "Description": {
 "type": "string"
 },
 "Direction": {
 "type": "string"
 },
 "DisableGridEditing": {
 "type": "boolean"
 },
 "DraftVersionVisibility": {
 "type": "integer"
 },
 "EnableAttachments": {
 "type": "boolean"
 },
 "EnableFolderCreation": {
 "type": "boolean"
 },
 "EnableMinorVersions": {
 "type": "boolean"
 },
 "EnableModeration": {
 "type": "boolean"
 },
 "EnableRequestSignOff": {
 "type": "boolean"
 },
 "EnableVersioning": {
 "type": "boolean"
 },
 "EntityTypeName": {
 "type": "string"
 },
 "ExemptFromBlockDownloadOfNonViewableFiles": {
 "type": "boolean"
 },
 "FileSavePostProcessingEnabled": {
 "type": "boolean"
 },
 "ForceCheckout": {
 "type": "boolean"
 },
 "HasExternalDataSource": {
 "type": "boolean"
 },
 "Hidden": {
 "type": "boolean"
 },
 "Id": {
 "type": "string"
 },
 "ImagePath": {
 "type": "object",
 "properties": {
 "DecodedUrl": {
 "type": "string"
 }
 }
 },
 "ImageUrl": {
 "type": "string"
 },
 "IrmEnabled": {
 "type": "boolean"
 },
 "IrmExpire": {
 "type": "boolean"
 },
 "IrmReject": {
 "type": "boolean"
 },
 "IsApplicationList": {
 "type": "boolean"
 },
 "IsCatalog": {
 "type": "boolean"
 },
 "IsPrivate": {
 "type": "boolean"
 },
 "ItemCount": {
 "type": "integer"
 },
 "LastItemDeletedDate": {
 "type": "string"
 },
 "LastItemModifiedDate": {
 "type": "string"
 },
 "LastItemUserModifiedDate": {
 "type": "string"
 },
 "ListExperienceOptions": {
 "type": "integer"
 },
 "ListItemEntityTypeFullName": {
 "type": "string"
 },
 "MajorVersionLimit": {
 "type": "integer"
 },
 "MajorWithMinorVersionsLimit": {
 "type": "integer"
 },
 "MultipleDataList": {
 "type": "boolean"
 },
 "NoCrawl": {
 "type": "boolean"
 },
 "ParentWebPath": {
 "type": "object",
 "properties": {
 "DecodedUrl": {
 "type": "string"
 }
 }
 },
 "ParentWebUrl": {
 "type": "string"
 },
 "ParserDisabled": {
 "type": "boolean"
 },
 "ServerTemplateCanCreateFolders": {
 "type": "boolean"
 },
 "TemplateFeatureId": {
 "type": "string"
 },
 "Title": {
 "type": "string"
 }
 }
}

 

 

 

 

 Tags (because this text input can sometimes ruin stuff):

SharePoint, SharePoint List, SharePoint Lists, List, Lists, URL, List URL

Comments

*This post is locked for comments