4

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
  1. get the Context (X-RequestDigest):

    dev1projects/PWA/_api/contextinfo 
    [POST empty body]
    
  2. Pick a Project:

    dev1projects/PWA/_api/ProjectServer/Projects?$Top=1
    [GET]
    
  3. 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]
    
  4. 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"}
    
  5. 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.

  • Any luck on updating custom project lookup fields? Be very interested to know :-) – user42810 May 29 '15 at 4:50
  • I wound up pushing that piece to the v2. So I only have theory on this. I think you can update the value of the custom field with the ID number of the list option you wish to set. I would try the updateNumberProperty action first. Then I would try the updateGuidProperty action second (using guid of the selected item instead of ID). Please note that I have not done POC, so I am not certain, but that is where I would start. – ghangas May 29 '15 at 16:48
4

OK folks, Here is the answer for how to codelessly update a project from outside PWA when you need to update enterprise custom fields.

Get the property GUID

dev1projects/PWA/_api/ProjectServer/Projects('theguidi-just-pick-from-theprojectabove')/CustomFields [GET]

retrieve d/results/(the index of the field you want to update)/Id

Update the Field

dev1projects/PWA/_api/ProjectServer/WorkflowActivities/updateTextProperty [POST]

{"projectId":"f1e76bad-014a-e411-940e-00155d017536",
"propertyId":"91266190-7d3f-e411-940d-00155d017536",
"value":"This is gonna be really great"}

To update something other than a text field test drive these URLs that I grabbed straight from the SDK:

updateBooleanProperty
updateCurrencyProperty
updateDateTimeProperty
updateGuidProperty
updateIdeaListItemStatus
updateIntegerProperty
updateNumberProperty
updateProjectStageStatus
updateTextProperty

What if I need to update a lookup field? I don't know yet. But I will know by the end of next week. In the meantime, thanks for reading, and I hope you find this useful...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.