10/23/2015

SharePoint: Set a Calculated Hyperlink Column from a Workflow

The following applies to SP 2010 and SP 2013 and should work in SP 2007.

You want a calculated column for a hyperlink, but can't create one. (you can't embed working HTML into the calculation.) So… you consider a workflow to create the data for a hyperlink column.

Some things in SharePoint are obvious, while others are not. Setting a calculated hyperlink field to a new URL from a workflow is one of the not so obvious. When you use the "Update List Item" action, click "this list", click Add and the "…" you get an Edit Hyperlink dialog box. While you can type manual text and URL entries, you can't build an expression. Your second choice is to click fx set a value from a variable. The problem is that this is not a simple string. The string in the variable needs to match this pattern, which includes a comma and one space:
    http://yoururl, your display text

 

Assumptions for the walkthrough:

  • You have a list with a course ID column named ID.
  • You have a course title column named Title.
  • You have an empty Hyperlink column named TheLink.

 

Steps:

  1. Open your site in SharePoint Designer 2010 or 2013 as appropriate.
  2. Click Lists and Libraries and click your list.
  3. Click the List Workflow button in the ribbon.
  4. Name your workflow and in SPD 2013 set the Platform Type to SharePoint 2010 or 2013 as desired..
  5. Click OK.
  6. Click the Action dropdown and click Set Workflow Variable.
    image
  7. Click workflow variable and create a new variable with a name like "LinkText", set the Type to String and click OK.
    image
  8. Click value and click the "" button.
  9. Create a string that will build your URL and your description, separated by a comma and a space. Click Add or Change Lookup to insert data from other columns. Then click OK.
    image
  10. Click the Action dropdown and click Update List Item. (for 2013: Set Field in Current Item)
    image
  11. Click this item, click Add, and select your hyperlink column. (for 2013: Click field and pick your hyperlink column and then click value and pick your variable.)
    image
  12. Click the fx button, select Workflow Variables and Parameters and then select your variable and click OK.
    image
  13. Click OK.
  14. Click Publish (in the ribbon).
  15. Test the workflow.
    1. Return to your list.
    2. Checkmark a list item.
    3. Click the ITEMS tab and click Workflows.
    4. Click the name of your workflow and click Start.
    5. Click the URL column and confirm that the link works.
  16. You will probably want to return to Designer and change the Workflow Settings to start the workflow when an item is created and when an item is changed.

 

 

.

No comments:

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.