2016-04-27 8 views

答えて

0

以下のコードを使用して、ルックアップテーブルでカスタムフィールドを作成して更新することができます。ただし、カスタムフィールドの更新や削除はできません。

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(); 
関連する問題