Skip to main content
July 2, 2021
Question

Expression Rule that returns a list

  • July 2, 2021
  • 2 replies
  • 0 views

How to create an expression rule that returns a list of data from a table in a database? 

I already queried in my data using a constant, now I need to create a rule that will returns a list of employee names from a database using the tables primary key (employee_id). 

2 replies

selvakumark
July 3, 2021

Hi,

You can create a simple query entity to return the employee names using the employee Id. You can find more about query recipes here
docs.appian.com/.../Query_Recipes.html

dastagirid756
July 4, 2021

Try to follow the following code. If you want to display full name (firstName and lastName), try to add query column for last name. Once you get all the employee first and last names, use foreach() to concatenate both the names.

a!queryEntity(
  entity: cons!AI_ENT_EMPLOYEE,
  query: a!query(
    selection: a!querySelection(
      columns: {
        a!queryColumn(
          field: "firstName"
        )
      }
    ),
    logicalExpression: a!queryLogicalExpression(
      operator: "AND",
      filters: {
        a!queryFilter(
          field: "id",
          operator: "in",
          value: {1,2,3,4,5}
        )
      },
      ignoreFiltersWithEmptyValues: true
    ),
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: 50
    )
  ),
  fetchTotalCount: false
).data