Posted on September 20th, 2014
In this post, you will learn how to get app web URL in Visual Studio 2013 workflows.
Please check my previous blog post, step1 and step 2 on how to create a list workflow.
We are sharing on workflows in SharePoint 2013 and Office 365 using Visual Studio 2013. These apply to both on-premises and online. All these blog posts based on SharePoint hosted apps.
Getting host web URL is very much straight forward, you can use WebUri activity that will give the host web URL whereas to get Appweb URL we need to use few more activities.
Let us check what are the activities required to get Appweb URL.
In this workflow, we will use below workflow activities to get App web URL in workflows using Visual Studio 2013.
To get current list item, we need to work with LookupSPListItem workflow activity. In the Visual Studio 2013 you can set input parameters of LookupSPListItem ItemId to the current item, ListId to the current list.
For the output create a DynamicValue variable here it is "ProductListItemProperties".
Once you have done with LookupSPListItem, click on Get Properties from LookupSPListItem activity it will add automatically GetDynamicValueProperties activity to the workflow.
In the GetDynamicValueProperties source will bet set automatically to "ProductListItemProperties" which is the output of LookupSPListItem activity.
Click on the dictionary ellipse that will open the screen below. Here add "_metadata/uri" and click on Populate Variables, which will create uri variable for you where we can store the list item URL.
Now add Assign activity to modify the List item URL so that we can get actual App web URL.
Use WriteToHistory activity to display the "Appweburl", so while testing we can see the actual URL.
Once you complete all the above steps, the workflow will get complete. Please see the screen below for the completed workflow.
Right-click on the project and click on deploy. Once you deploy it, add an item in the Products list, and it should start the workflow automatically. Now go to workflow status page to see the history info we have written for App web URL. Please see below screen.
You can find the sample code here https://github.com/devendrasv/WorkflowSamples-GetAppwebUrl
In this post you, have learned how to get app web URL in Visual Studio 2013 workflows.
Devendra Velegandla is a four-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2017) for Office Servers and Services MVP and SharePoint Server.He received the MCC award for his contributions in Microsoft MSDN/TechNet forums.He loves sharing articles, videos and tutorial on SharePoint and Office 365.