我正在尝试查找有关MS Dynamics CRM 4.0中字段长度的元数据 - 是否有人知道元数据服务中是否提供此信息?我试着查看AttributeMetadata类,但在那里找不到任何东西。然而,字段长度确实出现在MS的元数据浏览器中,因此必须以某种方式访问它。
答案 0 :(得分:2)
如果您知道该属性是字符串或ntext属性,则可以将AttributeMetadata对象强制转换为StringAttributeMetadata对象,并且该对象具有这些字段的最大长度。
答案 1 :(得分:1)
Thanx @Matt 工作起来很有魅力。我使用它如下:
StringAttributeMetadata stringAttributeMetadata = (StringAttributeMetadata)attributeMetadata;
recordToBeUpdated[recordFieldLogicalName] = recordFieldValue.Length < stringAttributeMetadata.MaxLength.Value ? recordFieldValue : recordFieldValue.Substring(0,stringAttributeMetadata.MaxLength.Value - 1);