Skip to main content
July 25, 2022
Question

Join two entities using CDT

  • July 25, 2022
  • 3 replies
  • 0 views

a!localVariables(
  /* Query the parent */

  local!Employee: a!queryEntity(
    entity: cons!TOC_EmployeeEntity, 
    query: a!query(
      selection: a!querySelection(
        columns: {        
          a!queryColumn(field: "Employeeid"),
          a!queryColumn(field: "Departmentid"),

        }
      ),      
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: -1
      )
    ),

  ).data,
  
  /* Query the many-to-one child */
  local!Department: a!queryEntity(
    entity: cons!TOC_DepartmentEntity,
    query: a!query(
      selection: a!querySelection(
        columns: {        
          a!queryColumn(field: "Departmentname"),
          a!queryColumn(field: "Departmentid"),

        }
      ),      
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: -1
      )
    ),

  ).data,
  
  a!gridLayout(
    label: "EmployeeDetails",
    /*instructions: "Seleccionados: " & local!selected & local!selectedItems,*/
    headerCells: {
      a!gridLayoutHeaderCell(label: "Employeeid"),
      a!gridLayoutHeaderCell(label: "DeparmentName", align: "LEFT")

    },
    rows: a!forEach(
      items: local!Department,
      expression: a!gridRowLayout(
        id: fv!index,
        contents: {
          a!richTextDisplayField(

            value:{ 
              a!richTextItem(

                text:fv!item.Departmentid,
                color: "#1a0000",
                size: "SMALL"
              )}
          ),
          a!richTextDisplayField(
            value:{ 
              a!richTextItem(
                text:fv!item.deparmentname,
                color: "#1a0000",
                size: "SMALL"
              )}
          )


        }
      )  
    ),

  )
)

how to join the employee and department?

    3 replies

    Participating Frequently
    July 26, 2022

    Hi, you can either create a record having the relationship between these two entities or you can create a view in the database.
    Check the below link.

    docs.appian.com/.../record-type-relationships.html

    harshitb6843
    July 26, 2022

    The question is not super clear. You want to join two tables but all the joining happened either in table, or in record or in the CDT. 
    What are you trying to achieve in this expression rule?