0

I have list with 500+ records. There is a hyperlink column called "TargetURL". As all of us know SP saves hyperlink in ["http://portal.site.com/sitecoll/doclib/Forms/someview.aspx", description ] format.

I have a workflow and I need to extract the doclib portion from the URL segment so I can get the document library name. Possible?

Substring? but how ? any tips will be appreciated.

2 Answers 2

0

This worked for me but I had to put first result in a variable and then add another build string action

http://[^/]+/[^/]+/

http://portal.cab.com/SalessiteCollection/October2012Library/Forms/customview.aspx Result: October2012Library/Forms/customview.aspx (you can store this in a variable)

(/Forms.*)

October2012Library/Forms/customview.aspx Result: October2012Library

1
  • Bill: This worked. Just 2 steps. If someone can combine both regex into one that would be even great. LOL. Thanks
    – M. Todd
    Commented Oct 8, 2012 at 18:05
0

Yes,

Have you tried this?

SPWeb web = SPContext.Current.Web;
string listname = String.Empty;
try
{
    SPList list = web.GetList(HttpContext.Current.Request.RawUrl);
    if (null != list)
    {
        listname = list.Title;
    }
}
catch (System.IO.FileNotFoundException ex) 
{
    //... Handle the exception 
}
4
  • Daniel: Not sure how this helps me. I have 1 list with 500+ records. And there is a hyperlink column that's populated with links to various document libraries. I am simply trying to get the document library name from the hyperlink column.
    – M. Todd
    Commented Oct 8, 2012 at 16:46
  • With this code, changing the "HttpContext.Current.Request.RawUrl" by your url, you will get the Document Library name... But I agree that is not performatic. In your case, there will be a pattern like you posted site/sitecoll/doclib... it will always be this way? Commented Oct 8, 2012 at 16:48
  • sharepoint.stackexchange.com/questions/40712/… almost looks like it. I dont see any substring after or before function in WF. they are only available xslt.
    – M. Todd
    Commented Oct 8, 2012 at 16:48
  • var url = "site/sitecoll/doclib/Forms/AllItems.aspx"; var docLib = url.Replace("http://", string.Empty).Split('/')[2]; Commented Oct 8, 2012 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.