How to import the sales/purchase lines to the Sales/purchase order page using code unit/Xmlport

RkpSadu
Member Posts: 6
Want to import the Item number,Quantity,Unit Price in the Purchase line in purchase order page
0
Answers
-
What have you tryed so far?For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0
-
Created Xml,Created Codeunit also.
codeunit is:
OnRun(VAR Rec : Record "Sales Header")
SalesHeader.RESET();
SalesLine.RESET();
CLEAR(LineNo);
LineNo:=0;
IF SalesHeader.GET(Rec."Document Type",Rec."No.") THEN BEGIN
SalesHeader."Sell-to Customer No.":=Rec."Sell-to Customer No.";
SalesLine.SETRANGE("Document No.",SalesHeader."No.");
IF SalesLine. FINDSET THEN
LineNo:=SalesLine."Line No."+10000
ELSE
LineNo:=10000;
CLEAR(InsertSalesLine);
InsertSalesLine.INIT;
InsertSalesLine.VALIDATE("Document Type",SalesHeader."Document Type");
InsertSalesLine.VALIDATE("Document No.",SalesHeader."No.");
InsertSalesLine.VALIDATE("Line No.",LineNo);
InsertSalesLine.INSERT(TRUE);
InsertSalesLine.VALIDATE(Type,InsertSalesLine.Type::Item);
SalesOrderXmlFile := 'C:\Multiple\NewSalesOrder.xml';
UPLOADINTOSTREAM('Import','',' Xml Files (*.txt)|*.txt',SalesOrderXmlFile,XmlStream);
IsImported :=XMLPORT.IMPORT(XMLPORT::ImportSalesLine,XmlStream); //error throwing here(False).
IF (IsImported = TRUE) THEN
MESSAGE('The import from XML is complete.')
ELSE
MESSAGE(GETLASTERRORTEXT);
END;0 -
Without knowing what your XMLPort looks like, and where exactly the error occurs, it's impossible to tell what the issue is.
However, the rest of your code has some issues as well:- You don't VALIDATE SalesHeader."Sell-to Customer No.", meaning a LOT of fields will not be filled in.
- You use FINDSET on SalesLine to determine the last used "Line No.". That's not going to return you what you want. You must use FINDLAST
- You don't MODIFY either the SalesHeader or SalesLine.
0 -
Property Value
Indentation 1
NodeName Line
NodeType Element
SourceType Table
SourceTable Sales Line
VariableName <Sales Line>
SourceTableView <Undefined>
ReqFilterHeading <>
ReqFilterHeadingML <>
CalcFields <Undefined>
ReqFilterFields <Undefined>
LinkTable Sales Header
LinkTableForceInsert <Yes>
LinkFields Document No.=FIELD(No.)
Temporary <No>
AutoSave <Yes>
AutoUpdate <No>
AutoReplace <No>
Width <0>
NamespacePrefix <Undefined>
MinOccurs <Once>
MaxOccurs <Unbounded>0 -
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions