Returning the Site/Project name to a SharePoint designer workflow using the site URL or a Web Service Call

Posted By Posted by: Dan Stopher on July 20, 2016

Blog_Orange Bar Skinny

Recently I was developing a notification workflow that would send an email to a user. For context, I wanted to include the name of the site in the email. I assumed this would be easy enough, but you know what they say about assumptions.  😉

 

Approach 1:

Return the URL and decompose it until only the site name is left.
It’s simple and predictable approach displayed below:

Img_1

Which worked immediately  🙂

The steps in summary were:

  • Set a variable (e.g. SiteName) to equal the current site URL
  • Replace the known prefix “https://sharepoint.com/” with a space character
  • Then find the first remaining “/” and return its position to an index variable
  • Then use the “Extract Substring from index of String” action to return a variable that returns only the Project/Site name from the URL


Note: While developing such a workflow, I return each variable to the history log so I can see what the workflow is doing. I have removed all of these logging lines from the above screenshot in the interest of showing only the key lines in the image.

 

Approach 2:

Call a HTTPs Web Service in combination with a Data dictionary.
It’s more sophisticated – and took me longer to get working due to tweaks that seemed environment specific – although the end result was more satisfying.

Img_2

The steps were:

  • Read Mokhtar Bepari’s comments here
  • Build a dictionary
  • Call the web service – using the Current Site URLImg_3
  • Ensure the properties of the Web Service line are as below:

    Img_4
  • Ensure you return the Title using the following command “Get d/Title” as below:

    Img_5

 

Conclusion:

Approach 1 is quick and simple and easy to understand/troubleshoot.

Approach 2 is great for more advanced users but requires a deeper technical knowledge.

Leave a comment and let me know which approach works for you.

 

 


Blog Posted In Blog Posted In: Blog, How to, SharePoint
Blog Posted In 

One thought on “Returning the Site/Project name to a SharePoint designer workflow using the site URL or a Web Service Call”

  1. Thanks for the walkthrough mate.
    Although Approach 1 seems much more easier, but I felt while executing approach two gave me more control and had me understanding what is needed.

Comments are closed.