XMLport losing global variable when inserting line records Nav 2009

dsummer
Member Posts: 7
When creating an import for a Sales Document XML file, where the file import is to create the Sales Invoice No for the Header, then attach several Sales Lines, I'm finding that the Global Variable that the SH.No. is assigned to is lost when the Sales Lines section is reached.
Code behind the Sales Header table section inserts the header correctly, and the SH No. is assigned to a global variable, but the code behind the Sales Line table section doesn't have the value in the global variable when the lines are to be inserted at that point. I've added a message to screen to show me what values are missing, and it's the DocNo and SalesHeader."No." that are blank.
Can you help with suggestions for what I'm doing wrong, or what else needs to be done to fix this?
XMLport layout
Node Name Node Type Source Type Data Source
RentalBills Element Text <RentalBills>
RentalBill Element Table <Sales Header>(Sales Header)
ClientId Element Text <ClientId>
RentalBillLineItems Element Text <RentalBillLineItems>
RentalBillLineItem Element Table <Sales Line>(Sales Line)
Description Element Text <Description>
TotalDays Element Text <TotalDays>
Rate Element Text <Rate>
RentalCharge Element Text <RentalCharge>
Import file layout
<?xml version="1.0"?>
<RentalBills>
<RentalBill>
<ClientId>MGCC0015</ClientId>
<RentalBillLineItems>
<RentalBillLineItem>
<Description>AR336</Description>
<TotalDays>366</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$36.60</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>AR80</Description>
<TotalDays>122</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$12.20</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>HE110</Description>
<TotalDays>244</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$24.40</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>Industrial // Industrial Cylinder :: Acetylene :: AC145</Description>
<TotalDays>244</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$24.40</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>OX125</Description>
<TotalDays>34</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$3.40</RentalCharge>
</RentalBillLineItem>
</RentalBillLineItems>
</RentalBill>
</RentalBills>
Code behind Sales Header
SalesHeader.VALIDATE("Document Type",SalesHeader."Document Type"::Invoice);
SalesHeader."No." := '';
SalesHeader.INSERT(TRUE);
DocNo := SalesHeader."No.";
Code behind Sales Lines
MESSAGE('line doc %1, line %2, Desc %3, sh %4',DocNo,LineNo,Description,SalesHeader."No.");
SalesLine.VALIDATE("Document Type",SalesLine."Document Type"::Invoice);
SalesLine.VALIDATE("Document No.",DocNo);
SalesLine.VALIDATE("Line No.",LineNo);
SalesLine.INSERT(TRUE);
Code behind the Sales Header table section inserts the header correctly, and the SH No. is assigned to a global variable, but the code behind the Sales Line table section doesn't have the value in the global variable when the lines are to be inserted at that point. I've added a message to screen to show me what values are missing, and it's the DocNo and SalesHeader."No." that are blank.
Can you help with suggestions for what I'm doing wrong, or what else needs to be done to fix this?
XMLport layout
Node Name Node Type Source Type Data Source
RentalBills Element Text <RentalBills>
RentalBill Element Table <Sales Header>(Sales Header)
ClientId Element Text <ClientId>
RentalBillLineItems Element Text <RentalBillLineItems>
RentalBillLineItem Element Table <Sales Line>(Sales Line)
Description Element Text <Description>
TotalDays Element Text <TotalDays>
Rate Element Text <Rate>
RentalCharge Element Text <RentalCharge>
Import file layout
<?xml version="1.0"?>
<RentalBills>
<RentalBill>
<ClientId>MGCC0015</ClientId>
<RentalBillLineItems>
<RentalBillLineItem>
<Description>AR336</Description>
<TotalDays>366</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$36.60</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>AR80</Description>
<TotalDays>122</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$12.20</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>HE110</Description>
<TotalDays>244</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$24.40</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>Industrial // Industrial Cylinder :: Acetylene :: AC145</Description>
<TotalDays>244</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$24.40</RentalCharge>
</RentalBillLineItem>
<RentalBillLineItem>
<Description>OX125</Description>
<TotalDays>34</TotalDays>
<Rate>$0.100</Rate>
<RentalCharge>$3.40</RentalCharge>
</RentalBillLineItem>
</RentalBillLineItems>
</RentalBill>
</RentalBills>
Code behind Sales Header
SalesHeader.VALIDATE("Document Type",SalesHeader."Document Type"::Invoice);
SalesHeader."No." := '';
SalesHeader.INSERT(TRUE);
DocNo := SalesHeader."No.";
Code behind Sales Lines
MESSAGE('line doc %1, line %2, Desc %3, sh %4',DocNo,LineNo,Description,SalesHeader."No.");
SalesLine.VALIDATE("Document Type",SalesLine."Document Type"::Invoice);
SalesLine.VALIDATE("Document No.",DocNo);
SalesLine.VALIDATE("Line No.",LineNo);
SalesLine.INSERT(TRUE);
Thanks
Debbie
Debbie
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