Project Server : How To Run Project Server Workflow From Code

We  were working on a requirement where we wanted to create a Project in PWA and push it to a particular workflow stage through code.

Creating the project is easy task and is implemented by QueueCreateMethod to create project . To Run the project workflow so that it can reach to  a particular stage we can use  RunProjectWorkflow  of  svcWorflow.WorkflowClient  Class . This method submit the workflow for a particular project . This method does the similar job like clicking on a  Submit button from PWA UI. If you need to by pass multiple stages run this method multiple times .

Below code describes how to use this method :

 private SvcWorkflow.WorkflowClient workflowClient; 
 workflowClient = new backendWorkFlow.WorkflowClient("basicHttp_WorkFlow");
 workflowClient.RunProjectWorkflow(new Guid("3876fec7-6126-496b-8537-23e78c9924f6")); // provide the Guid of the project

 To set the enpoints for the workflow service following is the configuration in configuration file :

   
   <endpoint address="<Your PWA URL>/_vti_bin/PSI/ProjectServer.svc"
               behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding"
               bindingConfiguration="basicHttpConf" contract="SvcWorkflow.Workflow"
               name="basicHttp_WorkFlow" />