how to get the nested CDT Data

I have an Employee CDT and Documents CDT(One to many Relation Ship between them) documents table has foreign key empId ,i wanted to get the documents based on empId (foreign key)

if i write expression like

 a!queryEntity(
entity: cons!DOCUMENTS_DETAILS,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1
),
filter: a!queryFilter(
field: "empId"( as foreign key in  documents table but empId field is not there  in Documents CDT),
operator: "in",
value:7
)
)
).data


so i am getting following error The field [empId] does not exist.. in such case how to get the nested CDT Data.

  Discussion posts and replies are publicly visible

Parents
  • Hi Kiran,

    If you are trying to use empId as a filter in your query, but there is no empId in the documents CDT (even if the DB table has the EMP_ID column), you will get this error message. If you add the empId field to the document CDT, the query should work fine. If you are trying to get information from the employee cdt by going through the document table first, I would recommend creating a DB view that has the relevant fields from both the document CDT and the employee CDT. Then you can create a query to call that view and query with both doc information and employee information and return both doc and employee info. using a!selection() in the query entity can also help you only pull back certain fields from the query if you wanted to do something like returning only employee fields, so the datasubset is structured like the employee cdt.

    Hope this helps,
    Alex
  • It would probably be much more efficient to go the route of creating a view. Most DBMS implementations are much faster at joining data sets than Appian is. Do all your joins in the database to get your view. Only use Appian to query the view.
Reply Children
No Data