Skip to main content
stephenk0001
Known Participant
March 7, 2024
Question

Replace queryEntity with queryRecordType

  • March 7, 2024
  • 4 replies
  • 4 views

Hi team

Here is my scenario:

I am busy changing my application to get rid of CDTs and use Record Types instead.

As I understand it this means I have to change any query using queryEntity to queryRecordType.


Here is an example of an existing expression:

{
  a!entityData(
    entity: cons!SAM_DSE_SOFTWARE_STATUS,
    data: reject(
      fn!isnull,
      a!forEach(
        items: {
          {
            uuid: cons!SAM_UUID_SOFTWARE_STATUS_APPROVE,
            name: "Approve",
            order: 1
          },
          {
            uuid: cons!SAM_UUID_SOFTWARE_STATUS_BACKLIST,
            name: "Backlist",
            order: 2
          },
          {
            uuid: cons!SAM_UUID_SOFTWARE_STATUS_REJECT,
            name: "Reject",
            order: 3
          },
          
        },
        expression: a!localVariables(
          local!status: rule!SAM_getSoftwareStatusByUUID(uuid: fv!item.uuid),
          if(
            isnull(local!status),
            'type!{urn:com:appian:types:SAM}SAM_SoftwareStatus'(
              id: null,
              uuid: fv!item.uuid,
              name: fv!item.name,
              createdBy: loggedInUser(),
              createdOn: now()
            ),
            null
          )
        )
      )
    )
  )
}

/* the query returns 
"
Time   16 ms (View Performance)

Type   List of EntityData

Value   

FormattedRawExpression
List of EntityData - 1 item
EntityData
entity[Data Store Entity:"0d6bc9c3-8d19-403a-9c2a-213a9c1428d2@94148"](Data Store Entity)
dataList of Variant - 0 items
*/



/*This is the rule referenced by the expression above.

The query returns a status value when a UUID is entered*/

if(
  or(isnull(ri!uuid), ri!uuid = ""),
  null,
  a!localVariables(
    local!datasubset: a!queryEntity(
      entity: cons!SAM_DSE_SOFTWARE_STATUS,
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "uuid",
              operator: "=",
              value: ri!uuid
            )
          },
          ignoreFiltersWithEmptyValues: true
        ),
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 1)
      ),
      fetchTotalCount: false
    ),
    if(
      rule!APP_isEmptyArray(local!datasubset.data),
      null,
      cast(
        'type!{urn:com:appian:types:SAM}SAM_SoftwareStatus',
        local!datasubset.data
      )
    )
  )
)

 I need a few pointers on how to go about changing these using queryRecordType

4 replies

stefanhelzle0001
Brainy
March 7, 2024

I am not sure what you are looking for. The biggest difference between CDTs and Record types is the syntax addressing fields.

stephenk0001
Known Participant
March 7, 2024

I'm looking for an example so I can understand how I need to adapt the queryEntity expressions - e.g., do I need to use the  statement:


if(
rule!APP_isEmptyArray(local!datasubset.data),
null,
cast(
'type!{urn:com:appian:types:SAM}SAM_SoftwareStatus',
local!datasubset.data
)

if I am using a record type to pull the data?

stefanhelzle0001
Brainy
March 7, 2024

queryRecordType returns the data field already in the correct type.