Skip to main content
brindas358855
December 4, 2025
Question

To get the condition ri!age[18

  • December 4, 2025
  • 2 replies
  • 0 views

 I have the following requirement:

In the backend table called conditions I have the columns called operator and value which have the values < and 18

I need to check the condition if the incoming is age is less than 18 then display true

That is if( ri!age<18, true(), false()).  Here I need to get the values of the operator and value from the back end table,  I am using query record to get the condition table output.  How can I achieve this?

    2 replies

    shubhama926776
    December 4, 2025

    You have to build similar below logic.
    Make sure all operator should be present in appian as constant. 

    
    a!localVariables(
    /* Simulate query record output from conditions table */
    local!conditionData: {
      operator: "<",
      value: 18
    },
    
    /* Your incoming age */
    local!age: 16,
    /*ri!age, */
    
    /* Evaluate condition dynamically */
    local!result: choose(
      wherecontains(
        tostring(local!conditionData.operator), 
        {"<", ">", "=", "<=", ">=", "!="}
      ),
      local!age < tointeger(local!conditionData.value),      /* < */
      local!age > tointeger(local!conditionData.value),      /* > */
      local!age = tointeger(local!conditionData.value),      /* = */
      local!age <= tointeger(local!conditionData.value),     /* <= */
      local!age >= tointeger(local!conditionData.value),     /* >= */
      local!age <> tointeger(local!conditionData.value)     /* != */
    ),
    
    /* Display result */
    local!result
    
    )

    mikes0011
    Brainy
    December 4, 2025

    Small nitpick, now that we have a!match(), i think we should consider the legacy function "choose()" as deprecated, since match() is more flexible, offers more code clarity, and has the ability to not error on an invalid index passed.  plus, you wouldn't have to bend over backwards to turn the list of operators into a positional index, but could instead directly address each operator.

    a!localVariables(
      /* Simulate query record output from conditions table */
      local!conditionData: a!map(
        operator: "<",
        value: 18
      ),
    
      /* Your incoming age */
      local!age: 20,
      /*ri!age, */
    
      /* Evaluate condition dynamically */
      local!result: a!match(
        value: local!conditionData.operator,
        
        equals: "<",  then: local!age < local!conditionData.value,
        equals: ">",  then: local!age > local!conditionData.value,
        equals: "=",  then: local!age = local!conditionData.value,
        equals: "<=",  then: local!age <= local!conditionData.value,
        equals: ">=",  then: local!age >= local!conditionData.value,
        equals: "!=",  then: local!age <> local!conditionData.value,
    
        default: null()
      ),
      
    
      /* Display result */
      local!result
    )