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 Reply Children
  • 0
    Certified Lead Developer
    in reply to Silas B. Ferreira
    How would you make this refresh-always behavior? Could you please provide me some example? 

    Variables declared in a!localVariables() with default settings (i.e. without using "a!refreshVariables()" to set non-default behaviors) will default to "refresh on referenced variable change" of TRUE and other refresh styles set to FALSE.  When local variables are used inside an expression rule like this, then that rule is used on an interface, it can lead to some tricky and unintuitive weird behaviors when in some instances, one would expect the value to update, but it doesn't.  In this case if a new primary key is passed in, it WOULD update the result, but in some other corner cases it might not.