Use fields from other table -- Report Designing

In report designer, how do I get a field from anothere table? Some background… I have taken the “G/L Register” report 10019 and saved as “Vendor Register” report 50014. The reason I use peport 10019 was for the creation date. I would like to put vendor name in the report. I have Vendor Ledger Entry in the section desingner as a body and indent from G/L Register. The Textbox that I setup was and put that in sourceExpr for properties. In C/AL Globals I put a line in variables as PurchInvoiceHeader as a Record and Subtype Purch. Inv. Header. When I run the report I do not get the report to pull Vendor Name from the Purch. Inv. Header table. I have played with C/AL Code but still nothing. What have I missed? The information is in navision in different table but how do I put them together?

One thing is missing → you never read the record, that you want to use. Defining a global and filling the “source expression” of a text box does not perform an automatic GET. So what you have to to is that … Go to the data item “Vendor Ledger Entry” and press F9. That will bring you to the data item triggers. In the trigger OnAfterGetRecord you have to place that code: if not PurchInvoiceHeader.GET(“Document No.”) then clear(PurchInvoiceHeader); This code reads the “Purchase Invoice Header” that you want to use and does not run into an error if the Header is not found. That could happen if you delete the posted and printed invoices after a certain time. When the record cannot be found then the record-variable is cleared. That should work.

C/AL Global Vend - Type:Record - Vendor On your “Vendor Ledger Entry” on After Get Record. Vend.GET(“Vendor No.”); On your Section add a text Box Source = Vend.Name This will display the vendor Name for you. Easy as that. David Cox email:

That would not cover diverse vendors. I don’t know if that is the right translation - a vendor number, that is used for several one time vendors. That’s why i would keep it as David Garrett had it before - i would take the name from the Purchase Invoice Header, not from the vendor-table.

Thank You, I first tried using rmotzer ideal but could not get any vendor names from the table purchinvoiceheader to show on my report. However, I then tried David Cox way to see the vend table. The vendor names do show up on my report now. I do need more testing. On reports that came with Navision it looked like they used setrange in the onpredataitem not onaftergetrecord. Why? I still have alot to change and test on this report. You have helped alot. Thanks, David Garrett

One more question When you set the record how do you know what field to use? When I setup Vend.Get(“Vendor No.”), why did I use Vendor No. not Name?

GET gets a record based on primary key value(s); Vendor No. not Name is the primary key for the Vendor table.