Skip to main content
kavyam0002
Brainy
Jan 27, 2022 9:19 AM UTC
Solved

Expression rule for multiple table

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 

    stewart.burchell
    Employee
    Jan 27, 2022 9:28 AM UTC

    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
    Employee
    Jan 27, 2022 9:28 AM UTC

    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
    Brainy
    Jan 27, 2022 9:38 AM UTC

    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
    Employee
    Jan 27, 2022 9:55 AM UTC

    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
    Brainy
    Jan 27, 2022 9:56 AM UTC

    I agree.