Why isn't there a default query record function like this following one in Appian which I made by myself

Description:

rule!OE_QueryOneRecordTypeByForeignKey(recordType, fkField, value)

Gets a record based on its foreign key field value

recordType (RecordType): queried record type

fkField (Record Field): foreign key field

value (Number (Integer)): integer value searched

a!localVariables(
  local!queryData: a!queryRecordType(
    recordType: ri!recordType,
    filters: {
      a!queryFilter(
        field: ri!fkField,
        operator: "=",
        value: ri!value,
        
      ),
      
    },
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 1)
  ).data,
  if(
    a!isNotNullOrEmpty(local!queryData),
    local!queryData[1],
    null
  )
)

if it was OE_QueryRecordTypeByForeignKey, then you simply remove the [1] indexing

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    There are several reasons. In my experience, there is no catch all expression. E.g. your code example would not work in a UI refresh scenario because you use a local variable without a refresh-always behaviour.

    Next, I am a huge fan of expressive expression names and really prefer a XYZ_GetCaseRecordById() over a generic XYZ_GetSomeRecordsWithAnAndlessListOfOptions().

    But there are (number of Appian developers) + 1 opinions.

Reply
  • 0
    Certified Lead Developer

    There are several reasons. In my experience, there is no catch all expression. E.g. your code example would not work in a UI refresh scenario because you use a local variable without a refresh-always behaviour.

    Next, I am a huge fan of expressive expression names and really prefer a XYZ_GetCaseRecordById() over a generic XYZ_GetSomeRecordsWithAnAndlessListOfOptions().

    But there are (number of Appian developers) + 1 opinions.

Children