I have a reusable workflow on library to fill the values in a list. I also want to get library name value to be filled in list' one column. Probably using stringbuilder and using some string manipulation on the url of current library Any idea?

  • I think a calculated column can solve you problem. Apr 2 '15 at 12:58
  • thanks Amal, I am able to get whole url in string builder like mysitecollection/sites/sitename/library/item.jpg... but I want library out of this url. Can you let me know the formula to het this out in calculated column
    – Aquarius24
    Apr 2 '15 at 13:47
  • You can add a new Calculated column to library and set formula =LibraryName. Also you can concatenate additional data along with it. Apr 2 '15 at 13:49
  • I cant add column in library because columns are coming from content type and adding a column will not shows it in workflow, instead I have to get whole url in list column and then manipulate that there
    – Aquarius24
    Apr 2 '15 at 13:51

While you cannot get the list TITLE this way, you should at least be able to get the list URL through a somewhat round-a-bout way. It will require two new columns on your content type and a new step in the workflow:

  1. Create a new site column (single line of text) and call it "Path"
  2. Add the new "Path" column to your content type
  3. In your reusable workflow, add a new step that sets the field "Path" in the current item to the relative URL of the current item, minus whatever you can strip off like web app URL and/or document name. Note: There are third-party workflow extensions that can make extracting a substring easier.
  4. Add a new site column (calculated column) to your content type and call it "LibraryPath"
  5. In your calculated column formula, use a combination of FIND and LEFT/RIGHT to strip off any remaining parts from the item's absolute URL. In the end, you should have only the list URL left (ex - "SharedDocuments"). When stripping out URL parts, you can usually use "/" as your waypoint.

For a full list of the text functions available in a calculated column, click here. Unfortunately, you will need to figure this part out yourself since every URL is different. Basically, you want to count the number of characters until a slash, then strip out that number of characters (+1 to remove the slash as well).

UPDATE: Here is a blog post showing how you can use Excel to test your formulas before putting them into a calculated column.

Also, please note that if you're accessing the full range of columns behind a library - such as with XSLT - there is a column called @FileDirRef which returns only the site-collection-relative URL of the library. Unfortunately, this column isn't available to either a calculated column or a SharePoint Designer workflow.

UPDATE 2: Also, keep in mind that a third-party workflow system, such as Nintex Workflows, may allow you to simply extract the current library name right off the bat. You can also do this via the SharePoint API if coding your own workflow in Visual Studio. Vanilla SharePoint does not offer this functionality, however.

UPDATE 3: Last one, I promise. If your workflow is 2013 compatible, you may be able to get the current list/library name through a web service call in your workflow. I've never tried getting this value specifically, so I'm not sure. Here is a reference to using the functionality.

Related Question: Get string out of url in calculated column


If you're developing the workflow in Visual Studio, you can use the following code to access the Title property of the Item's Parent List.

// Get the item the workflow is running on.
SPListItem item = workflowProperties.Item; 
// Get it's parent list/library title.
string libraryTitle = item.ParentList.Title.ToString();
// Set the column value.
item["Library Title"] = libraryTitle;
// Commit the changes.

If you don't want to update modified/modified by or create a version use the following instead of item.Update();


yes, it is possible to get the name of the list/library in Reusuable workflow:

1) create a association parameter (LibraryName) from 'Initiation Form parameters' option.

2) Then associate your workflow with the list/library it will ask for the parameter (LibraryName), enter the name and click on ok.

3) log/use the variable(LibraryName) in the workflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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