I am using a workflow to create a project in project server 2013. This seems like a fairly common operation, but I need to set a few pieces of information when I create the project that are not available in the constructor.
Process Outline
for my own purposes I am using Chrome app DHC for creating these requests.
I use headers:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
get the Context (X-RequestDigest):
dev1projects/PWA/_api/contextinfo [POST empty body]
Pick a Project:
dev1projects/PWA/_api/ProjectServer/Projects?$Top=1 [GET]
Check out the project:
dev1projects/PWA/_api/ProjectServer/Projects('theguidi-just-pick-from-theprojectabove')/checkOut() //Add Header X-RequestDigest:0xTheStringFromTheContextQuery(d/GetContextWebInformation/FormDigestValue) [POST empty body]
Update the Draft item:
dev1projects/PWA/_api/ProjectServer/Projects('projectid')/Draft/update() //Add Header X-RequestDigest:0xTheStringFromTheContextQuery(d/GetContextWebInformation/FormDigestValue) [POST] {"__metadata":{"type":"PS.DraftProject"},"Name":"Test 679"}
Check In the Draft:
dev1projects/PWA/_api/ProjectServer/Projects('theguidi-just-pick-from-theprojectabove')/Draft/checkIn() //Add Header X-RequestDigest:0xTheStringFromTheContextQuery(d/GetContextWebInformation/FormDigestValue) [POST empty body]
For step 4 I have seen a couple of examples that I have not been able to replicate success with. So I am coming to you for help.
Chris Givens Solution for updating owner made an entry in this question about how to accomplish an update tot he owner, but I have not been able to replicate his solution.
I need to update enterprise custom fields as well, so if you could please look for a solution to either updating a field like owner, or enterprise custom fields I would appreciate it.
In addition, I am working with Infopath and sharepoint designer workflow. So far my project is codeless and if possible I would like it to remain that way so I do not need admin deployment or approval.
UPDATE:
After some digging it turns out that the /draft/Update() is creating a queue job visible in the Central Admin Queue Jobs. I successfully changed Something in the Project using method 1 in step 4. I just need to hammer out the syntax for a successful update...
UPDATE:
Ok, I can repeatedly change the name field. Woot for progress. See my code in step 4. Now, I need to find a way to use this process to update the Finish date and several enterprise custom fields...
UPDATE:
Major breakthrough!
So I was browsing the SDK and found that the workflow web services for project server have a few interesting entries...
dev1projects/PWA/_api/ProjectServer/WorkflowActivities/CreateProjectFromListItem
[POST]
body:
{"webId":"78c039d0-f64e-493b-bf81-e5c857578c54",
"listId":"138936e6-753b-4143-8be3-37bdbb0957ea",
"itemId":"2",
"eptId":"09fa52b4-059b-4527-926e-99f9be96437a"}
it is late, and I need to go home, but please be aware that these guids will not work for you :->
So, that allows me to create a project from a list item. d/result (i think) has a project guid in it.
Then, I can use:
dev1projects/PWA/_api/ProjectServer/WorkflowActivities/updateTextProperty
[POST]
{"projectId":"03a2693e-d949-e411-940e-00155d017536",
"propertyId":"91266190-7d3f-e411-940d-00155d017536",
"value":"This is gonna be great"}
to store a value in the project's enterprise custom field.
I do not really want to make a web service call to populate each field on this project, but after nearly giving up I think there might be a path to success...
I would happily give my reputation points to someone who can clean this up into a clean solution. Bonus points for finding a solution to updating multiple fields with a single httprequest...
UPDATE:
The list item that you use to create the project from only passes in the title, so you are on your own for required fields. Also, it looks like the list needs to be in the same site collection with PWA.