如何实际编辑Project Server 2010的自定义字段

时间:2013-04-10 11:35:20

标签: sharepoint sharepoint-2010 project-server ms-project-server-2010

您好我想要实际编辑Project Server 2010的自定义字段,但我不知道我在哪里做错了。以下是代码,

请在这方面帮助我

ProjectSoapClient projectSvc = new ProjectSoapClient();
            CustomFieldsSoapClient customfieldSvc = new CustomFieldsSoapClient();
            CustomFieldDataSet fieldDefs = customfieldSvc.ReadCustomFields(string.Empty, false);

Guid projectId = new Guid(projGuid);
            ProjectDataSet projectDs = projectSvc.ReadProject(projectId, ListProjects.Project.DataStoreEnum.WorkingStore);

        foreach (ProjectDataSet.ProjectCustomFieldsRow cfRow in projectDs.ProjectCustomFields.Rows)
        {
            CustomFieldDataSet.CustomFieldsRow fieldDefinition = fieldDefs.CustomFields.Single(
                    cfd => cfd.MD_PROP_UID == cfRow.MD_PROP_UID);

            //if (cfRow.FIELD_TYPE_ENUM == 21 || cfRow.FIELD_TYPE_ENUM == 15) //if it is a choice field
            //{
                if (fieldDefinition.MD_PROP_NAME == "ProductCategory")
                {
                    cfRow.TEXT_VALUE = newValue;
                }
            //}
        }
        Guid sessionUid = Guid.NewGuid();
        Guid jobUid = Guid.NewGuid();
        if (!IsProjectCheckedOut(projectId))
        {
            projectSvc.CheckOutProject(projectId, sessionUid, "Updating CF");
            jobUid = Guid.NewGuid();
            projectSvc.QueueUpdateProject(jobUid, sessionUid, projectDs, false);
        }
        jobUid = Guid.NewGuid();
        projectSvc.QueuePublish(jobUid, projectId, true, SPContext.Current.Site.Url);
        projectSvc.QueueCheckInProject(jobUid, projectId, true, sessionUid, "Updating CF");

1 个答案:

答案 0 :(得分:0)

也许是因为你首先发布了这个项目。它也只适用于QueueCheckInProject函数。

另一个原因可能是,您正在使用迭代搜索的行尚未可用,您必须先将其添加到项目数据集中!

你应该等待完成结账,更新和签到!

查看我的博客文章了解更多详情: http://www.geeklife.ch/dev/update-project-server-2010-customfields-over-psi/

或者我在这个主题中的回答: Setting custom fields using the PSI - Microsoft Project Server