/// <summary> /// Create user-defined field. /// </summary> /// <param name="owner">Main entity type this UDF belongs to.</param> /// <param name="type">Intrinsic data type for the field.</param> /// <param name="name">Label for the field.</param> /// <param name="progId">Optional. Defaults to SuperOffice:{0} where {0} is the next available number for the data type.</param> /// <param name="tooltip">Optional. Determines the fields tooltip.</param> /// <returns></returns> public UserDefinedFieldInfo CreateOrUpdateUserDefinedField(UDefType owner, UDefFieldType type, string name, string progId = "", string tooltip = "") { UserDefinedFieldInfo udField = null; using (UserDefinedFieldInfoAgent udfAgent = new UserDefinedFieldInfoAgent()) { //Defaults... //if (fieldType == UDefFieldType.ShortText) // info.TextLength = 20; //else if (fieldType == UDefFieldType.LongText) // info.TextLength = 40; udField = udfAgent.CreateUserDefinedFieldInfo(owner, type); udField.Type = owner; udField.FieldType = type; udField.FieldLabel = name; if (!string.IsNullOrEmpty(progId)) { udField.ProgId = progId; } if (!string.IsNullOrEmpty(tooltip)) { udField.Tooltip = tooltip; } udField = udfAgent.SaveUserDefinedFieldInfo(udField); } return(udField); }
public void PublishUserDefinedFields(UDefType owner) { using (UserDefinedFieldInfoAgent udfAgent = new UserDefinedFieldInfoAgent()) { udfAgent.SetPublishStartSystemEvent(owner); udfAgent.Publish(owner); } }
public void DeleteUserDefinedField(UDefType owner, string labelOrProgId) { var udfList = GetUserDefinedFieldList(owner); var listItem = udfList.FirstOrDefault( l => l.FieldLabel.Equals(labelOrProgId, StringComparison.InvariantCultureIgnoreCase) || l.ProgId.Equals(labelOrProgId, StringComparison.InvariantCultureIgnoreCase)); if (listItem != null) { using (UserDefinedFieldInfoAgent udfAgent = new UserDefinedFieldInfoAgent()) { udfAgent.DeleteUserDefinedFieldInfo(listItem.UDefFieldId); } } }