0

I have been working on a web part that lives on a SharePoint site in a Project Web App instance, and interacts with Project Server using the Project REST API.

I need to be able to get tasks based on the value of a local custom field (not enterprise), and I'm having a heck of a time doing that using REST, because apparently if a local custom field does not have a value for a particular task, then that property simply does not exist on that task, which messes up the query for tasks that do have a value assigned because the server will come back with a 400 Bad Request error with the detail

Field or property "LocalCustom_Published_[GUID]_[GUID]" does not exist.

even though it does exist for the tasks I'm actually trying to find.

(See some of my other trials and tribulations here.)

I recently discovered (rediscovered?) that there is a JSOM for Project Server that is extremely similar to the SharePoint JSOM: you do context.get_current(), load this, load that, then executeQueryAsync() to get the results.

With the SharePoint JSOM, I know that you can get items using a CAML query, which is functionally equivalent to using an oData $filter in a REST request - you're basically saying "give me all the items where this particular field has this specific value."

So, is there some kind of equivalent functionality in the Project Server JSOM? I have not been able to find any examples... can you use a CAML query against Project Server? Or is there some other way to get tasks with a specific value in a specific field?

1 Answer 1

1

Unfortunately I think the answer is no. The JSOM is great and yes like you say similar to the SP JSOM (same backend processquery, similar syntax etc etc), however the methods all simply map back to the old server side PSI API methods. That is the same for JSOM, CSOM and REST (REST being the unlucky one as not all methods have been mapped).

The problem you have is that the database (/ binary blob in client) does not store null values like you might expect. No record is created for a field value if no value has ever been set, as you have seen.

Unfortunately the solution in my experience is to handle those 400 errors and continue. Ugly yes but unavoidable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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