Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

object model or the web services, to determine the url of the document

  Asked By: Caitlin    Date: Jul 28    Category: Sharepoint    Views: 866

I have a ListID (guid - uniqueidentifier) and an ItemID (int) for a
document in a document library, either in a WSS team site or in a
SPS area.
Is it possible, using only the object model or the web services, to
determine the url of the document without:
1. Querying the database directly, and
2. Iterating through all the site collections and webs


I know that if I were to query the database directly for a WSS site,
I can simply run this query to determine the URL:

SELECT '/' + DirName + '/' + LeafName
WHERE ListId = @ListId AND
DoclibRowId = @ItemID

However, querying SQL directly in production is not a good approach
for obvious reasons.



2 Answers Found

Answer #1    Answered By: Patricia Richardson     Answered On: Jul 28

You'll need to iterate through each site  of each virtual server, then within each web  on each site, then each splist on each web and check the SPList GUID and then when you find the list, verify that the SPList item with the GUID you are looking for is there. You can then look at the ParentWeb object  to get the URL of the web, the name of the list, and the file name to get your complete URL.

Answer #2    Answered By: Alexandra Patterson     Answered On: Jul 28

I recognized that the iterating through all the site  collections and their webs was an option and mentioned it in my post. Unless I'm mistaken, I don't think I would have to iterate through the SPList objects in my SPWeb object  since I already have the ListID GUID. I think I can just pass the GUID into the list "name" parameter to get the actual list.

Dim myList As SPList = myWeb.Lists([ListID - GUID])

However, what I'm wondering is if there is a more direct way since the above brute force method will tend to be slow.

Am I really forced to take the iterative path? I hope not but it's kinda looking like I am.