Wednesday, June 17, 2015

Dynamics NAV 2015 - Create XMLPort to import flat file

http://www.archerpoint.com/blog/Posts/nav-development-import-flat-files-xmlports


  • Create XMLPORT
    • Enable Request Page, select filter
    • Define Root - Node Name "root"
      • Define Destination Table - select table source
        • Define Source columns - select field source
      • Define CAL code on Destination - Import OnBeforeInsertRecord


//Get Doc No from Request Page
IF NOT (GiftRegLine.GETFILTER("No.")='') THEN
GRDocNo := GiftRegLine.GETFILTER("No.");

GiftRegLine.INIT;

//Populate Lines
IF EVALUATE(Qty,Quan) THEN BEGIN;
EVALUATE(Prc,Price);
NextLine += 10000;

GiftRegLine."No." := GRDocNo;
GiftRegLine."Line No." := NextLine;
GiftRegLine."Item No." := ItemNo;
GiftRegLine.Quantity :=Qty;
GiftRegLine.SellingPrice := Prc;
END
ELSE BEGIN
//Skip import line if not a valid line
currXMLport.SKIP;
END;



  • Create Button on Page>Actions
    • Set button to Run Object XMLPORT objectNo

No comments:

Post a Comment