Get workflow initiator information in SharePoint hosted Add-in(app)

Posted on September 19th, 2014

In this post, you will learn how to get workflow initiator information in SharePoint hosted app using Visual Studio 2013. In the most of the workflows we work, Initiator information is very important because we need to send an email to Initiator based on workflow status, etc.

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 here based on SharePoint hosted apps.This post is applicable for both SharePoint 2013 online and SharePoint 2013 on-premises.

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

Let us check what are the basic workflow activities we use to get the workflow initiator information.

Workflow Activities:

Below are the list of workflow activities you will learn while going through this post.

  • Lookupworkflowcontextproperty
  • LookupSPPrincipalId
  • LookupSPUser
  • GetDynamicValueProperties

Let's start creating an app to test our workflow.

Step 1: Create SharePoint Hosted APP Project:

We will create a SharePoint hosted app in our example, we will use the same steps in future blog posts related to custom workflows.

Open visual studio 2013, click on new project select Apps under the office/SharePoint from which select project type as Apps for SharePoint 2013.

SharePoint Hosted app Project

Enter your project name, here it is InitiatorInfo, then click OK. It will open the wizard to create the project.

SharePoint Hosted app Project

Select the site where you want to deploy the app. "".

Hosting option should be : SharePoint-hosted.

Click Finish. It will create the project.

Right-click on the project add a List called Products, in which we will use standard Custom List Definition. If you haven't  done creating a list within the app, please check this post here.

Once you have done with the List, let's create the workflow.

Step 2: List workflow:

We will use list workflow that will be running on Products list.(Please see below screens).

Right click on the project, add [ New Item]  Select workflow and click on [Add]

List Workflow

In the below select type of the workflow, in our case this is List workflow.

List Workflow

Select the list on which you want to run the workflow, Here it is Products and creating new "WorkflowToHistory" and "WorkflowTaskList" for storing workflow history and task info.

List Workflow

Click Next, and choose the starting options accordingly. In this, I am setting to start the workflow automatically when an item added.

Now you have added the workflow successfully to the project. Let's add the activities to the workflow.

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

Step 3: Adding workflow activities to get Initiator Information:


Add Lookupworkflowcontextproperty from the tool box to the sequence. This activity helps to get workflow

  • Associator
  • Initiator
  • Association Name
  • Instance Id
  • Current site URL
  • Current Item URL
  • List Name
  • List Id

In this example, we need only Initiator.

In the below figure, we are setting Property Name to Initiator and setting result to a variable called Initiator of type string. For variable check the "Workflow variables" section below. From the Initiator, we will get the user name. Our requirement is to get user email, so we will use Initiator variable in the other workflow activities to get the email address.

Workflow Toolbox

Workflow Variables:

Below is the list of workflow variables we have used in this example.

Workflow Variables


LookupSPPrincipalId gives user Id based on userName. Let's pass the Initiator variable here get Output Result as InitiatorId.



Once you have user Id, you can get user properties based on that Id. Here we will use LookupSPUser activity to get the email property. Here the InitiatorProperties variable is of type "Dynamicvalue".


After completing the properties of LookupSPUser, click on properties that will automatically add "GetDynamicValueProperties" activity to the workflow.


In this activity, the source is the output of LookupSPUser, which is InitiatorProperties variable.


Now click on Dictionary ellipses from the above screen that will open the screen below. From the path choose Email and in the Assign To, you can create your variable or click on "Populate Variables" to populate variable automatically for you.

Let's add the "WriteToHistory" activity to log the "Initiatoremail" variable.

Completed workflow:

Once you complete all the steps, the workflow looks below. I have updated the "Sequence" to Initiator Info, so that whoever sees this workflow they will understand the functionality.

Workflow Initiator Information

Step 4: Testing

Right-click on the project and click on deploy. Once we 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 Initiator email. Please see below screen.

Workflow History

Code repository:

You can find the SharePoint hosted app project here


In this post, you have learned how to get workflow initiator information in SharePoint hosted app using Visual Studio 2013.

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

› Get workflow initiator information in SharePoint hosted app

Join 8,000 subscribers and receive instant access to

Devendra's Library of Resources for SharePoint Developers

About Author

Devendra Velegandla is a five-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2019) for Office Apps and Services, 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.