The BrightWork web service includes the endpoint Create Project so that you can use the tool of your choice to provision a new Project Site. In this article we provide instructions in the context of using Nintex Workflow; you can modify the process to accommodate whichever tool you choose to use.
The web service functionality allows the user to create projects based on parameters passed in by the user (using JSON); the service will be called from the parent web.
https://samplesite/Sites/BWSite/Projects/_vti_bin/BrightWork.svc/CreateProject - Creates a new top-level project in BWSite.
https://samplesite/Sites/BWSite/Projects/ProjectA/_vti_bin/BrightWork.svc/CreateProject - Creates a new subproject under Project A.
The Nintex workflow can be used with the existing Project Request Manager template, but ensure you disable the native BrightWork feature to create a Project from a Request. The workflow could also be employed in a standard SharePoint Custom List. This article will step through the process of building the Nintex Workflow.
The Nintex Workflow needs seven variables defined, three of which are needed for the Web Service Call and four that are needed to create the Project:
Variable |
Type |
PostResult |
Single line of text |
PostResultMultipleText |
Multiple lines of text |
XMLExtract |
Single line of text |
ProjectName |
Single line of text |
TemplateName |
Single line of text |
ProjectDescription |
Multiple lines of text |
ProjectManager |
Person or Group |
In Nintex, use the standard Set Variable Action to capture information from the Project Request form that will be passed to the Project Site.
Building and executing the Web request requires three actions:
Create a Web Request Action to capture the X-RequestDigest and store the information in the PostResultMultipleText variable.
URL: https://samplesite/Sites/BWSite/Projects/prm/_api/contextinfo
Content Type: application/x-www-form-urlencoded
Store Results: PostResultMultipleText
Create a Query XML Action to parse out the X-RequestValue from the XML captured in the previous action and store the information in the XMLExtract Variable.
XML from Variable: {WorkflowVariable:PostResultMultipleText}
Output using Xpath: //*[local-name()='FormDigestValue']
Store Results: XMLExtract
The final step is to create the Project Site using the X-Request Digest and populating the Project with your pre-defined variables:
URL: https://samplesite/Sites/BWSite/Projects/_vti_bin/BrightWork.svc/CreateProject
Content Type: application/json
Header Information:
{
"templateName":"{WorkflowVariable:TemplateName}",
"projectName":"{WorkflowVariable:ProjectName}",
"projectTitle":"{WorkflowVariable:ProjectName}",
"projectDescription":"{WorkflowVariable:ProjectDescription}",
"useParentTopNavigation":"True",
"addToParentTopNavigation":"True",
"addToParentQuickLaunch":"True"
}