How to get app web url in Visual Studio 2013 workflows



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. 

To learn more about Building workflows, click the image below and enroll in the FREE course.

Workflow Activities:

In this workflow, we will use below workflow activities to get App web URL in workflows using Visual Studio 2013.

  • LookupSPListItem
  • GetDynamicValueProperties
  • Assign
  • WriteToHistory

Adding workflow activities to get App web URL:

LookupSPListItem:

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.

LookupSPListItem

For the output create a DynamicValue variable here it is "ProductListItemProperties".

Workflow Variables:

Workflow Variables

Once you have done with LookupSPListItem, click on Get Properties from LookupSPListItem activity it will add automatically GetDynamicValueProperties activity to the workflow.

GetDynamicValueProperties

In the GetDynamicValueProperties source will bet set automatically to "ProductListItemProperties" which is the output of LookupSPListItem activity.

GetDynamicValueProperties

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.

ListItemUri

Assign:

Now add Assign activity to modify the List item URL so that we can get actual App web URL.

Assign Activity to Get App web Url

Use WriteToHistory activity to display the "Appweburl", so while testing we can see the actual URL.

Completed workflow:

Once you complete all the above steps, the workflow will get complete. Please see the screen below for the completed workflow.

Get AppwebUrl workflow

To learn more about Building workflows, click the image below and enroll in the FREE course.

Testing:

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.

Workflow History

Code Repository:

You can find the sample code here  https://github.com/devendrasv/WorkflowSamples-GetAppwebUrl

Conclusion:

In this post you, have learned how to get app web URL in Visual Studio 2013 workflows.

To learn more about Building workflows, click the image below and enroll in the FREE course.

› How to get app web url in Visual Studio 2013 workflows



Join 6,500 subscribers and receive instant access to

Devendra's Library of Resources for SharePoint Developers


About Author

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.