Skip to main content
kavyam0002
January 27, 2022
Solved

Expression rule for multiple table

  • January 27, 2022
  • 4 replies
  • 0 views

Hi,

can we write single expression rule to get data from multiple table, if it's possible how it can be simple example

like: select orders.orderid, customers.custername from order inner join customers on orders.customerid=customer.customerid

can we write such query in expression rule 

Thanks,

Kavya 

    Best answer by stewart.burchell

    In your conceptual model you need to separate the data model aspect from the data retrieval aspect. Expressions can retrieve data from a "data model" but not (easily) implement such a model.

    In your example you have two choices:

    1. create two different Record Types, one for Order and one for Customer, and then have Orders nested as a multiple under Customer. You can then use a!queryRecordType() to retrieve the data
    2. create a database VIEW which joins the data as you describe, then create a CDT from the VIEW and then an expression that contains a a!queryEntity() that retrieves data from that VIEW

    Note that 1., is essentially Appian's way of effectively implementing 2. without having to resort to creating database VIEWs.

    4 replies

    stewart.burchell
    January 27, 2022

    In your conceptual model you need to separate the data model aspect from the data retrieval aspect. Expressions can retrieve data from a "data model" but not (easily) implement such a model.

    In your example you have two choices:

    1. create two different Record Types, one for Order and one for Customer, and then have Orders nested as a multiple under Customer. You can then use a!queryRecordType() to retrieve the data
    2. create a database VIEW which joins the data as you describe, then create a CDT from the VIEW and then an expression that contains a a!queryEntity() that retrieves data from that VIEW

    Note that 1., is essentially Appian's way of effectively implementing 2. without having to resort to creating database VIEWs.

    harshitb6843
    January 27, 2022

    Hi there,

    stewart.burchell has already told you the two ways. Another approach can be to query 2 different tables by passing the output of one QE into another as input and then combining the result in a third expression rule. However, I would still prefer creating records and then using record relationships. 

    stewart.burchell
    January 27, 2022

    Yes, I inferred this was possible, but it's not an easy option and, frankly, why would you opt for this when there are much easier options available to you.

    harshitb6843
    January 27, 2022

    I agree.