Extracting the URL from Document Library’s Link type


Apparently in SP Online Document Library app, the Title field is not linked to the document. Last year, using Laura Rogers’ workaround, I created a workflow to extract the AbsoluteURL from the file name and attach it to the title of the file, which then got pasted into a new field called DocumentTitle.

Fast forward to Summer 2016:

Microsoft added the ability to add links to other documents into a document library. It generates a filename with a .url extension to hold the data. So now, the AbsoluteURL I was using in the workflow, is the actual file name of the URL listing (i.e. Employee Handbook.url) and not the URL of the file that is linked.
As an aside, Microsoft has not (yet) given us the ability to actually edit the link once we create the URL. Why, I don’t know, but it’s a one-time shot. If you need to change it, you need to delete the current one, and then add a new one, along with all the wonderful metatags.
The actual URL to the file or web address to which you want to link is hidden a new ShortcutURL field, and the contents of that field looks like this:
While I’m somewhat familiar with string manipulation, I didn’t know how to do this in a SharePoint Designer workflow, so I reached out to my awesome mentor, @duffbert, who sent me a screenshot of something similar he had found and then walked me through the logic. He is just awesome.

The solution:



Inside a new stage

  • Action: Set Workflow Variable
    • Name the variable: e.g. URLlink
    • Value: From the Current Item menu choose Shortcut URL
  • Action: Find substring in string (Output to Variable: index)
    • Substring = “Url”:”
    • String = “Variable: URLlink”
  • Action: do calculation
    • Calculate “Variable: Index” plus “7” (Output to variable:calc)
  • Action: Extract Substring from index of String
    (this line becomes Copy from string, starting at 0 (Output to Variable: substring)

    • String = “Variable: URLlink”
    • Starting at: “Variable calc”
  • Action: Find substring in string (Output to Variable: index1)
    • Substring = “}
    • String = “Variable: substring”
  • Action: Extract Substring of String from Index with Length
    (this line becomes Copy from string, starting at 0 for value characters (Output to Variable: substring1)

    • Value = “Variable: URLlink”, starting at “Variable: calc” for “Variable: index1” characters (Output to Variable: substring1)
  • Action: Replace Substring in String
    • String = \/ (backslash, forward slash)
    • String = /
    • String = “Variable: substring1” (Output to Variable: output)
Now, using the output variable, I can attach the File URL to the DocumentTitle field so when someone clicks on the Title name, it will actually open the file in the browser window, and not ask a user to download a funky Employee Handbook.url file.
The complete workflow now looks like this:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s