You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建Dataverse自定义属性时,如何设置只读的IsSearchable属性?

Dataverse自定义字符串属性IsSearchable设置问题解决

问题原因

IsSearchable是Dataverse的只读计算属性,无法直接赋值,它的取值由以下三个条件共同决定:

  • 字符串属性的MaxLength ≤ 4000(多行文本属性长度超过4000时默认不可搜索)
  • IsValidForSearch设为true
  • IsValidForAdvancedFind设为true

你之前的代码缺少MaxLength和IsValidForSearch的配置,因此即使设置了IsValidForAdvancedFind,系统仍会将IsSearchable设为false。

修改后的代码示例

attribute = new StringAttributeMetadata {
    // 注意SchemaName不能包含空格,需符合Dataverse命名规范(如自定义前缀+属性名)
    SchemaName = "new_solutionattribute",
    DisplayName = new Label("Attribute name", 1036),
    RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.ApplicationRequired),
    Description = new Label("Description", 1036),
    IsAuditEnabled = new BooleanManagedProperty(true),
    IsValidForAdvancedFind = new BooleanManagedProperty(true),
    IsValidForForm = true,
    // 添加IsValidForSearch配置
    IsValidForSearch = new BooleanManagedProperty(true),
    // 设置≤4000的长度值,根据业务需求调整
    MaxLength = 100,
    IsSecured = false
};

CreateAttributeRequest createAttributeRequest = new CreateAttributeRequest
{
    EntityName = "TableName",
    Attribute = attribute
};
createAttributeRequest["SolutionUniqueName"] = "SolutionUniqueName";
// ServiceClient _serviceClient已连接
_serviceClient.Execute(createAttributeRequest);

额外注意事项

  • SchemaName必须是合法标识符,不能包含空格、特殊字符,建议使用自定义解决方案前缀(如new_)避免命名冲突。
  • 如果需要创建多行文本属性(MaxLength>4000),则IsSearchable始终为false,此类属性无法被搜索。

内容的提问来源于stack exchange,提问作者EugeneDelage

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 05:12:27