Project Server 2013:根据JavaScript客户端对象模型或REST中的自定义字段过滤项目 [英] Project Server 2013: Filtering projects by custom field from JavaScript Client Object Model or REST

查看:56
本文介绍了Project Server 2013:根据JavaScript客户端对象模型或REST中的自定义字段过滤项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想要从Project Server中检索一些项目,然后更新一些自定义字段并使用JavaScript将项目写回Project Server。

因为我们的系统中有数千个项目,所以在将数据传送到浏览器之前,必须在自定义字段上应用服务器端过滤器。

Hi,

we want to retrieve some projects from Project Server, then update some custom fields and write the projects back to Project Server using JavaScript.
Because we have thousands of projects in our system, a server side filter on a custom field has to be applied before delivering the data to the browser.

I我知道使用LINQ可以过滤使用.NET CSOM的项目,但我在JavaScript的客户端对象模型中找不到任何类似的功能。

I know that filtering projects using the .NET CSOM is possible by using LINQ, but I couldn't find any similiar functionality in the Client Side Object Model for JavaScript.

我试过的另一种方法是使用REST API带有$ filter参数,但还没有运气。我总是得到一个错误,如"字段或属性"Custom_ddf18a84c993e2118b3200155d8c6d35"不存在。"我尝试了以下
网址:

/ _api / ProjectServer / Projects?$ filter = Custom_ddf18a84c993e2118b3200155d8c6d35%20eq%20%27Test%27

/ _api / ProjectServer /项目?$ filter = IncludeCustomFields / Custom_ddf18a84c993e2118b3200155d8c6d35%20eq%20%27Test%27

Another approach I tried was using the REST API with it's $filter parameter, but had no luck with it, yet. I always get an error like "Field or property "Custom_ddf18a84c993e2118b3200155d8c6d35" does not exist.". I tried the following URLs:
/_api/ProjectServer/Projects?$filter=Custom_ddf18a84c993e2118b3200155d8c6d35%20eq%20%27Test%27
/_api/ProjectServer/Projects?$filter=IncludeCustomFields/Custom_ddf18a84c993e2118b3200155d8c6d35%20eq%20%27Test%27

在REST响应中实现所有"_"在自定义字段名称中替换为"_x005f_";我还尝试使用"Custom_x005f_ddf18a84c993e2118b3200155d8c6d35"的变体......但没有成功。

Realizing that in the REST response all "_" in the custom field names are replaced by "_x005f_" I also tried the variants with "Custom_x005f_ddf18a84c993e2118b3200155d8c6d35"... without success.

使用默认属性,如"名称"和而是按预期工作。

Using a default property like "Name" instead works as expected.

我几乎无法相信不可能通过自定义字段过滤项目,所以任何人都可以给我一个暗示我在这里做错了吗?

I can hardly believe that it is not possible to filter projects by a custom field, so can anybody give me a hint what I'm doing wrong here?

有没有其他方法可以使用JavaScript客户端API实现这一目标?

Is there another way to achieve this using the JavaScript client side APIs?

感谢您的输入。

问候,

Gregor

推荐答案

现在可以使用以下方法完成:

This can now be done using the following:

/ _ api / ProjectData / Projects?

/_api/ProjectData/Projects?


filter = CustomFieldName eq'CFValue'
filter=CustomFieldName eq 'CFValue'

注意:'ProjectData'而不是'ProjectServer',自定义字段是使用它的名称而不是它的内部名称指定的。

Note: 'ProjectData' instead of 'ProjectServer', and the custom field is specified using it's name rather than it's internal name.


这篇关于Project Server 2013:根据JavaScript客户端对象模型或REST中的自定义字段过滤项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆