SourceExpr Filter ?


After finishing my 3days Navision Design Seminar, i was warmly welcomed back at the firm
and shortly after overflow with alot requests of modifying forms and reports. At the Seminar
i learned alot of things and now have a basic understanding on how to make and modify a few
things, but at the moment im stuck.

I need to insert and extra textfield into a report that displays out customercode for the selected
vendor. I first tryed to insert the Table Vendor were i found the CustermerCode into the DataItems,
but seeing there were allready allot of oder tables there i didn’t know were to place or link it.
so i came with the idea to Create a new Global var ‘CustomerCode’ with the DataType: Record
and the SubType with the table Vendor. In the Textbox property SourceExpr i now wanted to
select the global var CustomerCode and display the information, but im stuck at this point.

How do i get a link between the 2 differt tables and display the correct information, i figure i
need something like:

SourceExpr: CustomerCode.“Our Account No.” WHERE CustomerCode.No. EQUALS “Purchase Header”.Vendor.-Nr

If someone could push me in the right dirrection i would be very happy :slight_smile:

Bjorn de Jong

(ps. im on Navision 4.01)

Vendor.get(“Purchase Header”.“Vendor No.”);

Use Vendor.“Our Account No.” as Source Expression

I agree with Henrik,

best place to put the code "Vendor.GET(“Purchase Header”.“Vendor No.”) would be the OnAfterGetRecord trigger of the “Purchase Header” dataitem.

In fact you should always try to put code in the dataitem triggers and only if this is not possible you can put it on one of the sections triggers.

Thanks to the both of you, it worked like a charm, just one more question, could
you guys explain me that piece of code, i dont understand why this is working.

Vendor.GET(“Purchase Header”.“Vendor No.”)

That is actually quite easy.

Vendor is a variable (global) of the type record with the subtype vendor.

the command VENDOR.GET(VendorNo) retrieves the vendor from the database where the unique primary key equals the value in “VendorNo”

We know the vendor number we are looking for because the field “Vendor No.” of the purchase header contains the value.

After the GET we have a reference to the vendor like you would have with your

WHERE CustomerCode.No. EQUALS “Purchase Header”.Vendor.-Nr

In terms of SQL you could write

CustomerCode = ExecuteSQLCommand('SELECT DISTINCT * from Vendor WHERE “No.” EQUALS “Purchase Header”.“Vendor No.” ')

The result set (CustomerCode or Vendor - depends how you name your variable) consists of ONE record of the vendor table where you just need to extract the right field with the source expression: CustomerCode.“Our Account No.”.

Just imagine the “CustomerCode” variable being a pointer to an object (record) of the type Vendor and the “Our Customer No.” field being a property of the object.

This line actually equals the Navision statement Vendor.GET

Thanks Thomas that is a great dummyproof explanation.

In this case I close the topic and set to resolved ?


Always glad to be of any help !!!