Sometimes data from a setup table in Business Central will be required when building a list. For example, pulling the Company Name from the Company Information table or the LCY Code from the General ledger Setup table. Adding these tables can be tricky because there won’t be a field to join a setup table to the rest of the data you are retrieving from Business Central.
Below are the steps we can take using a Cross Join to join a setup table to a Business Central Query Builder list.
What is a Cross Join?
A Cross Join contains rows that combine each row from the upper data item table with each row from a lower data item table. A cross join does not apply any comparisons between columns of data items.
The Microsoft documentation has an example of the output when using a Cross Join between the Sales Header and Salesperson/Purchaser tables.
Adding General Ledger Setup table to a List
For my scenario I am going to take a list of Purchase Invoices and join it to the General Ledger Setup table so I can add the Local Currency Code to my list.
- Create a basic list joining the Purch. Inv. Header table to the Purch. Inv. Line table.
- Click + Add table
- Add the General Ledger Setup table
- Add any From field and To field you want
- Click Add table
- Select LCY Code from the General Ledger Setup tab
- Click on the line joining the General Ledger Setup table to your query
- Change the Join type to Cross join
- Publish the list
- Go back to the Popdock Dashboard and run your list.
- Notice that the LCY Code field is the same for every Invoice in the list
Using Cross Joined data in a Calculated Field
You can stop after you have added the column, but in my scenario I want to take some action based on the field I joined. I’m going to add a new calculated field that will replace the blank currency fields with the LCY Code.
- Open the Query Builder list again
- Navigate to the Fields tab and add a new Calculated field
- Provide a Name for the Calculated field
- Set the Type to String
- Enter the below Formula
- Click Go back to List
If(IsBlank({Currency Code}), {LCY Code}, {Currency Code})
- Run your list again, and add your Calcuated field to the response
- Notice that the new Calculated field is dynamically filling in the blank currency values
If you have questions about using cross joins in Query Builder, contact support@eonesolutions.com.