Recently, in one of my projects there was a requirement to create a SharePoint list workflow that triggers when an item is created, and that should result in creating a new list item on another SharePoint list which is created on some other SharePoint instance.
I knew the default copy list item activity will not work in this scenario as both lists are not on the same SharePoint site. The straight forward solution to this on top of my mind was to use ‘Call HTTP Service’ activity by calling SharePoint REST services with POST method, and create the item on another list. But this required to run the workflow with elevated permissions.[ Empower executives and employees across your organization to connect, converse, discover and work together at one central location to save time, increase productivity and boost engagement Know more at: Office 365 Intranet ]
In this blog, I will first talk about the required configuration to do this cross site stuff and then brief out the steps to call the SharePoint Rest Service:
Enable workflow elevated permissions
– Below are the high-level steps to do enable the workflow:
- Allow the workflow to use app permissions in a SharePoint Server 2013/Online site.
- Grant full control permission to the workflow.
- Wrap the call action inside app step.
You may follow the detailed steps from Workflow with elevated permissions by using the SharePoint 2013 Workflow platform
Note: You will need to enable the workflow elevated permissions on both the sites. I followed the below process:
- Get the App Id from the first site where the List workflow is created to Call HTTP Service as below
- Go to Site Settings, under Users and Permissions, and click Site app permissions.
- On the permission page, the App Identifier column displays the value. Here, copy the GUID value before @ symbol.
- With this App Id, enable the workflow elevated permissions where the SharePoint List workflow is created using this link – Workflow with elevated permissions by using the SharePoint 2013 Workflow platform
- Navigate to another SharePoint site where the list item is to be created [Note: This is required only when your lists are not on same site/site collection]
- Use the App Id you get in step 1 from first site and perform step 2 on this site.
More Interesting Read
Get the target metadata type for HTTP Call:
To do this you need the Odata service URL of the list where you need to create the list item. Use the below link and replace placeholders with actual values
Navigating this link displays xml/json in this search ‘
Now you are done with the required configurations to use Call HTTP Service activity to create item on another SharePoint site list.
For calling the SharePoint REST Service, you may refer this link – Using SharePoint REST services from workflow with POST method, which greatly helped me to quickly configure the workflow.
The changes to do in the created workflow are:
- Use the service URL https:////_api/web/lists/getbytitle(")/items of another site where you need list item to be created.
- Keep the ‘Call HTTP Service’ activity in the App Step.
- While configuring the Build dictionary which we call metadata, the type value should be the term value you get in the section ‘Get the target metadata type for HTTP Call’ instead of SP.Data.WorkflowItemsListItem
Once you are done with this, save and publish the workflow. Now your workflow is ready to test. When you create/update (depending on your configuration) a list item in current SharePoint list, it will create a list item in another SharePoint site list, the URL of which you configured in the workflow.
And this way you can update the list items on external SharePoint sites. Note that this process works on SharePoint 2013 List workflows only, as earlier versions do not have Call HTTP Service activity available.
Need Help in Sharepoint? Contact Us Now!