【问题标题】:PSI update resource custom field with lookup table (Project Server)PSI 使用查找表更新资源自定义字段 (Project Server)
【发布时间】:2016-08-21 18:48:35
【问题描述】:

有人可以给我看一个代码来更新带有查找表的企业资源自定义字段吗?已经在网上找了一些示例代码,但没有成功。

【问题讨论】:

    标签: server project psi


    【解决方案1】:

    您可以使用以下代码创建和更新带有查找表的自定义字段。但我们无法更新或删除内置自定义字段

    var projContext = new ProjectContext(projectServerUrl);
    
    CustomFieldCollection CustomField = projContext.CustomFields;
    EntityTypes Entitytype = projContext.EntityTypes;
    LookupTableCollection lookupTables = projContext.LookupTables;
    projContext.Load(CustomField);
    projContext.Load(Entitytype);
    projContext.Load(lookupTables);
    projContext.ExecuteQuery();
    
    CustomFieldCreationInformation NewfieldInfo = new CustomFieldCreationInformation();
    NewfieldInfo.Id = new Guid();
    NewfieldInfo.Name = "The Name";
    NewfieldInfo.Description = "The Description";
    NewfieldInfo.IsWorkflowControlled = true;
    NewfieldInfo.IsRequired = true;
    NewfieldInfo.IsEditableInVisibility = false;
    NewfieldInfo.IsMultilineText = false;
    
    LookupTable lookuptable = lookupTables.ToList().Find(x => x.Name == "LookupTableName");
    projContext.Load(lookuptable);
    projContext.ExecuteQuery();
    NewfieldInfo.LookupTable = lookuptable;
    
    NewfieldInfo.EntityType = Entitytype.ProjectEntity;
    NewfieldInfo.FieldType = CustomFieldType.TEXT;
    
    projContext.CustomFields.Add(NewfieldInfo);
    projContext.CustomFields.Update();
    projContext.ExecuteQuery();
    

    【讨论】:

      猜你喜欢
      • 2012-03-14
      • 2019-12-31
      • 2017-08-20
      • 2011-04-15
      • 1970-01-01
      • 2019-07-12
      • 2023-03-03
      • 2012-05-25
      • 2013-02-04
      相关资源
      最近更新 更多