cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Power Participant
Power Participant

Extract ListId from itemURL (GUID)

Hi

 

Im trying to figure out the best way to extract the listid (listname) from the itemURL and put that into a variable.

 

itemURL looks like this.

"https://cotonso.sharepoint.com/sites/myTestSite/_layouts/15/listform.aspx?PageType=4&ListId=%7B60A4DEE9-C5FB-4C15-B779-2A3795140BE3%7D&Source=https%3A%2F%2Fcotonso.sharepoint.com%2Fsites%2FmyTestSite%2FLists%2FEmail%2520Respond%2520Test%2FAllItems.aspx%3Fviewid%3Dddb7bc05%252D92e6%252D469f%252D8479%252D1c543ec5feb7&RootFolder=%2Fsites%2FmyTestSitet%2FLists%2FEmail%20Respond%20Test&ID=1&ContentTypeId=0x0100B43BD6C2CFD4CC4B943399522C4515A8",

Now i can see that this is the line that holds the listid: ListId=%7B60A4DEE9-C5FB-4C15-B779-2A3795140BE3%7D

And i know that i need to remove %7B and %7D to get the real listid.

 

But how do i do this the best way. I have tested split but imn ending up spliting multiple times and thats not very good.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Extract ListId from itemURL (GUID)

@JimmyWork 

Hi there!   You're very close!   You can still use Split (), which will put it into an array.  Then just add a [#] after to choose which element you want.  

 

As an example, if you did Split(<really long URL>,'%7B'), You end up with two elements:

 

[
"60A4DEE9-C5FB-4C15-B779-2A3795140BE3%7D&Source=https%3A%2F%2Fcotonso.sharepoint.com%2Fsites%2FmyTestSite%2FLists%2FEmail%2520Respond%2520Test%2FAllItems.aspx%3Fviewid%3Dddb7bc05%252D92e6%252D469f%252D8479%252D1c543ec5feb7&RootFolder=%2Fsites%2FmyTestSitet%2FLists%2FEmail%20Respond%20Test&ID=1&ContentTypeId=0x0100B43BD6C2CFD4CC4B943399522C4515A8"
]
 
Since the numbering starts at 0, and you want the second element, put a [1] at the end of the thing above:
Split(<really long URL>,'%7B')[1]
 
The next part is to grab everything until the first %7D, right?  We can either do that in a subsequent Compose step, or just wrap another Split around the first one and indicate we want the FIRST element of that array:
 
split(split(outputs('ReallyLongURL'),'%7B')[1],'%7D')[0]
 
This should give you the result you want:  60A4DEE9-C5FB-4C15-B779-2A3795140BE3
 
If Flow gets weird later because it thinks this is still an Array vs. a String, wrap a String() around the whole mess above:  String(split(split(outputs('ReallyLongURL'),'%7B')[1],'%7D')[0])
 
Keep us posted.
-Ed-
 
 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

 

View solution in original post

5 REPLIES 5
Highlighted
Super User II
Super User II

Re: Extract ListId from itemURL (GUID)

@JimmyWork 

Hi there!   You're very close!   You can still use Split (), which will put it into an array.  Then just add a [#] after to choose which element you want.  

 

As an example, if you did Split(<really long URL>,'%7B'), You end up with two elements:

 

[
"60A4DEE9-C5FB-4C15-B779-2A3795140BE3%7D&Source=https%3A%2F%2Fcotonso.sharepoint.com%2Fsites%2FmyTestSite%2FLists%2FEmail%2520Respond%2520Test%2FAllItems.aspx%3Fviewid%3Dddb7bc05%252D92e6%252D469f%252D8479%252D1c543ec5feb7&RootFolder=%2Fsites%2FmyTestSitet%2FLists%2FEmail%20Respond%20Test&ID=1&ContentTypeId=0x0100B43BD6C2CFD4CC4B943399522C4515A8"
]
 
Since the numbering starts at 0, and you want the second element, put a [1] at the end of the thing above:
Split(<really long URL>,'%7B')[1]
 
The next part is to grab everything until the first %7D, right?  We can either do that in a subsequent Compose step, or just wrap another Split around the first one and indicate we want the FIRST element of that array:
 
split(split(outputs('ReallyLongURL'),'%7B')[1],'%7D')[0]
 
This should give you the result you want:  60A4DEE9-C5FB-4C15-B779-2A3795140BE3
 
If Flow gets weird later because it thinks this is still an Array vs. a String, wrap a String() around the whole mess above:  String(split(split(outputs('ReallyLongURL'),'%7B')[1],'%7D')[0])
 
Keep us posted.
-Ed-
 
 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

 

View solution in original post

Highlighted
Power Participant
Power Participant

Re: Extract ListId from itemURL (GUID)

Solved by using: 

last(split(first(split(triggerBody()?['itemURL'],'%7D')),'%7B'))

If there is a better way please let me know

Highlighted
Resolver I
Resolver I

Re: Extract ListId from itemURL (GUID)


@JimmyWork wrote:

Solved by using: 

last(split(first(split(triggerBody()?['itemURL'],'%7D')),'%7B'))

If there is a better way please let me know


Hey, @JimmyWork , where are you getting the itemURL from?

 

There's a few ways of getting the listId, is all, and knowing where your itemURL is coming from would make it easier to work out the best way of getting that.

 

Highlighted
Power Participant
Power Participant

Re: Extract ListId from itemURL (GUID)

@eliotcole I'm getting it from a SharePoint list but a bit complicated because i use a flow to call another flow to make this flow work on all document libraries dynamically. So i don't know the itemURL as it will change and so will files, locations and so on to make it work as a global publishing flow on all document libraries, i use a SharePoint column and make that into a button that calls a flow and then parse the details to another flow.

Highlighted
Resolver I
Resolver I

Re: Extract ListId from itemURL (GUID)

Whoops, sorry, I might've misread your requirement, but I also might've found a better field to reference without all of the formatting hoo-has.

 

Basically, when you call any SharePoint item in the JSON of the request it provides a field called:

 

{link}

 

This field is the link to the list item itself, that form view you see sometimes.

 

That link contains the ListId that you're looking for ... an example:

 

https://contoso.sharepoint.com/sites/eliotflows/_layouts/15/listform.aspx?PageType=4&ListId=a7389512d0-9999-8888-7777-c540dfc0a76d&ID=1&ContentTypeID=0x0100B6FE75E93171C24DB0F8A6401CEED629

 

You could then strip the ListId value out using the methods you've mentioned, but not needing to worry about the HTML encoding.

 

But now the issue I see with that is how to get at it generically, but I would assume that you've already managed to do that.

 

In theory, though, the {link} item is in every single list item that you pull everywhere, all you have to do is access that field.

 

I'm searching further and running tests, now, and will let you know if I have more.

 

That said, I'd love to know the Parse JSON schema you're using to just get generic information about the list items.

 

When I try to create a schema (let's say below a "Get lists" > "Get items" flow), it breaks because the schema for one list is different to the schema for another. Unless you're dynamically creating the schema using secondary flows ... I suppose that's a roundabout, but onorous (for flow) way to do it, but I'm guessing you've found a way ...

 

------


I've also just published (or will soon ... I think it's in the 'approvals' area) a Blog Post (because I literally only just found out that they exist) about how to extract a list link purely from the GUID (because smart list creators change the list name imediately after making them 😉 ) ... It should be at the following URL, but might switch up if/when it publishes ... 
https://powerusers.microsoft.com/t5/Community-Blog-Staging-Private/Convert-SharePoint-ListId-GUID-to...

I use this in my "List of Lists" that I have on every single site, to create a full directory of lists that are created on the site, and update it with the current URLs, because (not a slight) Microsoft doesn't provide any real management of multiple lists.

 

I'm not flogging that, by the way, it just seemed relevant here.

 


@JimmyWork wrote:

@eliotcole I'm getting it from a SharePoint list but a bit complicated because i use a flow to call another flow to make this flow work on all document libraries dynamically. So i don't know the itemURL as it will change and so will files, locations and so on to make it work as a global publishing flow on all document libraries, i use a SharePoint column and make that into a button that calls a flow and then parse the details to another flow.


 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (6,703)