Skip to Content
Nov 29, 2022 at 08:30 AM

CAP: join in event handler doesn't work

230 Views Last edit Nov 30, 2022 at 05:36 AM 2 rev

Hi community,

I'm trying to join two tables in my Node.js event handler. Although the sql runs without error, the result is null.

I've confirmed that the join partner (BusinessPartnerSalesAreaData) does exist. Am I missing anything?

	const { BusinessPartnerBasicData, BusinessPartnerSalesAreaData } = this.entities

        const { SalesOrganization } = await SELECT 
                          .one (`${} as A`) 
                          .join (`${} as B`) 
                          .columns `B.SalesOrganization`
                          .where `A.ID = ${id}`<br>

If I execute 2 sqls sequentially I can get SalesOrganization.

        const { toSalesArea_ID } = await SELECT 
                                    .one (BusinessPartnerBasicData)
                                    .columns `toSalesArea_ID`
                                    .where `ID = ${id}`

        const { SalesOrganization } = await SELECT 
                                      .one (BusinessPartnerSalesAreaData) 
                                      .columns `SalesOrganization`
                                      .where `ID = ${toSalesArea_ID}`<br>

@sap/cds version: 6.3.2

Ive referenced the following threads.

Best regards,