QueryEntity - Result Type

Hi all,

We are in the process of converting some of our query rules to a!queryEntity() expression rules, since the latter is much faster in terms of execution time.

However, it looks like a!queryEntity returns the result of type "Any Type", and not the actual CDT like a query rule would return. This makes it difficult to work with the data afterwards on various interfaces & functions.

Does anyone know a generic way to cast the results into the desired CDT depending on the type of entity that's passed in?

  Discussion posts and replies are publicly visible

Parents
  • Have your query entity in a load variable, and then cast it as shown in the example below;

    load(
    local!DataSubset: a!queryEntity(
    entity: cons!COM_ENTITY_ABC,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    if(rule!COM_isNullOrEmpty(ri!Id),{},
    a!queryFilter(
    field: "Id",
    operator: "in",
    value: ri!Id
    ))
    }
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    )
    )
    ),
    if(
    local!DataSubset.totalCount > 0,
    cast(
    typeof(
    {
    'type!CDTname'()
    }
    ),
    local!DataSubset.data
    ),
    {}
    )
    )
Reply
  • Have your query entity in a load variable, and then cast it as shown in the example below;

    load(
    local!DataSubset: a!queryEntity(
    entity: cons!COM_ENTITY_ABC,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    if(rule!COM_isNullOrEmpty(ri!Id),{},
    a!queryFilter(
    field: "Id",
    operator: "in",
    value: ri!Id
    ))
    }
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    )
    )
    ),
    if(
    local!DataSubset.totalCount > 0,
    cast(
    typeof(
    {
    'type!CDTname'()
    }
    ),
    local!DataSubset.data
    ),
    {}
    )
    )
Children
No Data