Help needed on dataports

ResenderResender Member Posts: 119
edited 2012-10-23 in NAV Three Tier
So for my current project I have to export some data with dataports, for this I have to use data from 3 tables
*Company Information
*Cust. Ledger Entry
*Customer
(and roughly in this order)

So I looked it up how to do, I got the explanation just haven't been able to make it work. The dataport has to result in a csv file that follows this pattern
Company Information fields, Cust. Ledger Entry Fields,Customer fields,...
next record

So I thought to begin easy and do
Cust. Ledger Entry
Customer
dataport with the following code in the Customer OnBeforeRecord
Customer.SETFILTER("No.","Cust. Ledger Entry"."Customer No.");

But I'm getting the fields for customer under the lines of customer ledger entry and they also contain customers not in the ledger.
I'm looking into it further on my own, this is just to get some input from people who might know more then me

Answers

  • kinekine Member Posts: 12,562
    1) Do you want it for RTC or classic client? (I assume RTC, because you are posting into NAV Three Tier forum)
    2) On RTC you need to use XMLPort, not dataport
    3) If you want to combine more tables into one line, you need to write code for this (selec one "Master" table, base the export on it, and read the attached data from other tables through record variables).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • SavatageSavatage Member Posts: 7,142
    edited 2012-10-20
    I would use CLE as your dataitem.

    Variables:
    CompanyInfo Record Company Information
    Customer Record Customer
    CustomerField Text 30
    CLEField Text 30
    CompanyField Text 30

    OnAfterExportRecord()
    CompanyInfo.GET;
    Customer.GET("Cust. Ledger Entry"."Customer No.");

    CustomerField := Customer.Name; //sample export from table 1
    CLEField := "Cust. Ledger Entry".Description; //sample export from table 2
    CompanyField := CompanyInfo.Name; //sample export from table 3

    Dataport Fields:
    Enabled SourceExpr StartPos Width CallFieldValidate Format
    Yes CustomerField 0 0 No
    Yes CLEField 0 0 No
    Yes CompanyField 0 0 No
    OBJECT Dataport 50075 Test Dataport
    {
      OBJECT-PROPERTIES
      {
        Date=10/19/12;
        Time=[ 1:28:20 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        FieldStartDelimiter=<None>;
        FieldEndDelimiter=<None>;
        FieldSeparator=<TAB>;
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table21;
            OnAfterExportRecord=BEGIN
                                  CompanyInfo.GET;
                                  Customer.GET("Cust. Ledger Entry"."Customer No.");
    
                                  CustomerField := Customer.Name;
                                  CLEField := "Cust. Ledger Entry".Description;
                                  CompanyField := CompanyInfo.Name;
                                END;
    
          }
          FIELDS
          {
            {      ;     ;CustomerField        }
            {      ;     ;CLEField             }
            {      ;     ;CompanyField         }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          CompanyInfo@1000000000 : Record 79;
          Customer@1000000001 : Record 18;
          CustomerField@1000000002 : Text[30];
          CLEField@1000000003 : Text[30];
          CompanyField@1000000004 : Text[30];
    
        BEGIN
        END.
      }
    }
    
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Savatage wrote:
    I would use CLE as your dataitem.
    ...
    OBJECT Dataport 50075 Test Dataport
    
    }
    

    Dataports don't run on the RTC. As Kine said he needs to do this in an XML port.
    David Singleton
  • SavatageSavatage Member Posts: 7,142
    perhaps he posted in the wrong forum :-k
  • ResenderResender Member Posts: 119
    Savatage wrote:
    perhaps he posted in the wrong forum :-k

    Yes, I posted on the wrong forums, I only realised this after I submitted the message.(I've been practising on RTC for the past 2 months so force off habit ensued).

    On the other hand I do also have to make this for rtc later on so....
    I like to thank for the answers I'll try them out.

    Ok, tried out the suggestions/answers the worked :))
    Now the next problem I'm facing is:
    *Dynamic file nameThink I found the solution for this already
    *Filters passed along from a codeunit

    Solved and can this be moved to the correct forums
  • ResenderResender Member Posts: 119
    Savatage wrote:
    I would use CLE as your dataitem.

    Variables:
    CompanyInfo Record Company Information
    Customer Record Customer
    CustomerField Text 30
    CLEField Text 30
    CompanyField Text 30

    OnAfterExportRecord()
    CompanyInfo.GET;
    Customer.GET("Cust. Ledger Entry"."Customer No.");

    CustomerField := Customer.Name; //sample export from table 1
    CLEField := "Cust. Ledger Entry".Description; //sample export from table 2
    CompanyField := CompanyInfo.Name; //sample export from table 3

    Dataport Fields:
    Enabled SourceExpr StartPos Width CallFieldValidate Format
    Yes CustomerField 0 0 No
    Yes CLEField 0 0 No
    Yes CompanyField 0 0 No
    OBJECT Dataport 50075 Test Dataport
    {
      OBJECT-PROPERTIES
      {
        Date=10/19/12;
        Time=[ 1:28:20 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        FieldStartDelimiter=<None>;
        FieldEndDelimiter=<None>;
        FieldSeparator=<TAB>;
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table21;
            OnAfterExportRecord=BEGIN
                                  CompanyInfo.GET;
                                  Customer.GET("Cust. Ledger Entry"."Customer No.");
    
                                  CustomerField := Customer.Name;
                                  CLEField := "Cust. Ledger Entry".Description;
                                  CompanyField := CompanyInfo.Name;
                                END;
    
          }
          FIELDS
          {
            {      ;     ;CustomerField        }
            {      ;     ;CLEField             }
            {      ;     ;CompanyField         }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          CompanyInfo@1000000000 : Record 79;
          Customer@1000000001 : Record 18;
          CustomerField@1000000002 : Text[30];
          CLEField@1000000003 : Text[30];
          CompanyField@1000000004 : Text[30];
    
        BEGIN
        END.
      }
    }
    
    Ok, so noone made the comment the code for the CustomerField;CLEField & CompanyField should have been in OnBeforeExportRecord
  • SavatageSavatage Member Posts: 7,142
    :lol: I didn't realize I needed a disclaimer...
    Note: it's a sample dataport, created in about a minute, to point you in the right direction based on your question. They are just sample fields to produce a sample output. You can change it to any fields you need.
    But you are correct ..OnBeforeExportRecord() is the way to go.
    Thanks.
  • ResenderResender Member Posts: 119
    It worked it was just that the info of the first record was displayed on top of the second, I was kind of confused about what was going on untill it hit me like a sledgehammer
Sign In or Register to comment.