Code Problem

mkpjsrmkpjsr Member Posts: 587
Hi all,

I want to fetch the "Vendor Name" on "Posted Transfer Shipment Report", so i have added a field "vendor No." on Transfer Header and Transfer Shipment Header" with Table Relation as Vendor.
The field "Vendor No." is getting updated on post of the Transfer Order in Transfer Shipment Header table for that i have made changes to the code unit 5704
(TransShptHeader."Vendor No.":="Vendor No.";)

Now i want to fetch the Vendor Name on the "Posted Transfer Shipment" Report, so i have written the following code under OnPresection of "Transfer Shipment Line" Body section.

Following globals i have created:
TransShipLine->Record->Transfer Shipment Line
TransShipHeader->record->Transfer Shipment Header
VendorRec->Record->Vendor
VendorName->Text

//TransShipLine.RESET;
//TransShipLine.SETRANGE(TransShipLine."Document No.",TransShipHeader."No.");
IF VendorRec.GET(TransShipHeader."Vendor No.") THEN
VendorName:=VendorRec.Name;
But i am not able to fetch the Vendor Name,
Can anybody suggest me what is wrong with this code.

Comments

  • vijay_gvijay_g Member Posts: 884
    mkpjsr wrote:
    Hi all,


    //TransShipLine.RESET;
    //TransShipLine.SETRANGE(TransShipLine."Document No.",TransShipHeader."No.");
    IF VendorRec.GET(TransShipHeader."Vendor No.") THEN
    VendorName:=VendorRec.Name;
    But i am not able to fetch the Vendor Name,
    Can anybody suggest me what is wrong with this code.

    use if TransShipLine.findset then before vendorrec.get.
  • mkpjsrmkpjsr Member Posts: 587
    vijay_g wrote:
    mkpjsr wrote:
    Hi all,


    //TransShipLine.RESET;
    //TransShipLine.SETRANGE(TransShipLine."Document No.",TransShipHeader."No.");
    IF VendorRec.GET(TransShipHeader."Vendor No.") THEN
    VendorName:=VendorRec.Name;
    But i am not able to fetch the Vendor Name,
    Can anybody suggest me what is wrong with this code.

    use if TransShipLine.findset then before vendorrec.get.

    hi,
    its done
    what i did is , i wrote
    IF VendorRec.GET("Transfer Shipment Header"."Vendor No.") THEN
    instead of
    IF VendorRec.GET(TransShipHeader."Vendor No.") THEN

    its working, but i am not clear why [IF VendorRec.GET(TransShipHeader."Vendor No.") THEN]
    is not working
  • BeliasBelias Member Posts: 2,998
    edited 2010-02-12
    because you didn't initialize TransShipHeader variable with a proper get or find...(this means that you don't have any value in Transshipheader."vendor no.", and your get fails)
    i think that "Transfer Shipment Header" is instead the dataitem of your report, thus is automatically read by NAV.
    TIP: do not put code in the report sections, even if it is only for visibility purposes (e.g.: SHOWOUTPUT function), instead, in your case, you can put it under the onaftergetrecord trigger: in this way you will not shatter the code everywhere in the report.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mkpjsrmkpjsr Member Posts: 587
    Belias wrote:
    because you didn't inizializ TransShipHeader variable with a proper get or find...(this means that you don't have any value in Transshipheader."vendor no.", and your get fails)
    i think that "Transfer Shipment Header" is instead the dataitem of your report, thus is automatically read by NAV.
    TIP: do not put code in the report sections, even if it is only for visibility purposes (e.g.: SHOWOUTPUT function), instead, in your case, you can put it under the onaftergetrecord trigger: in this way you will not shatter the code everywhere in the report.

    Thanx for the suggestion
  • BeliasBelias Member Posts: 2,998
    a correction of my previous post:
    because you didn't initialize TransShipHeader variable with a proper get or find...(this means that you don't have any value in Transshipheader."vendor no.", and your "GET" fails)
    i think that "Transfer Shipment Header" is instead the dataitem of your report, thus is automatically read by NAV.
    TIP: do not put code in the report sections, UNLESS if it is only for visibility purposes (e.g.: SHOWOUTPUT function), instead, in your case, you can put it under the onaftergetrecord trigger: in this way you will not shatter the code everywhere in the report.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.