XMLport import sales order

matiqmatiq Member Posts: 8
Hi,

I work on 3rd party application that imports order to navision. Everything works properly but it doesn't insert value from option field like Location Code or Payment Method.

For example part of XML file:
...
<LocationCode>BIELY</LocationCode> 
<PaymentMethod>CARD</PaymentMethod> 
...

XML file is imported but without this two values.

Can anyone tell me what's the problem and how to fix it?

Thanks!

Answers

  • kinekine Member Posts: 12,562
    Those fields are not option field. They are code fields. But without more info like how the xmlport looks like it is hard to tell you more. It looks like inserting another value after these values are entered will overwrite them (like entering customer no. etc.). It means the order of how the fields are filled in is important.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matiqmatiq Member Posts: 8
    hi, thanks for reply.

    here is whole xmlport
    OBJECT XMLport 123456789 restaurantXMLportTest
    {
      OBJECT-PROPERTIES
      {
        Date=22.03.11;
        Time=21:44:28;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Permissions=TableData 36=rimd,
                    TableData 37=rimd;
        Direction=Import;
        Encoding=UTF-8;
        Format/Evaluate=C/SIDE Format/Evaluate;
      }
      ELEMENTS
      {
        { [{3E5C2D4F-071E-4A46-819E-5E693EA9CC13}];  ;Order               ;Element ;Text     }
    
        { [{3734D84D-971C-48A8-B3FD-328D114E8A42}];1 ;SalesHeader         ;Element ;Table   ;
                                                      VariableName=<Sales Header>;
                                                      SourceTable=Table36 }
    
        { [{E898DDE5-E710-4234-A6D9-3301180F47B7}];2 ;DocumentType        ;Element ;Field   ;
                                                      DataType=Option;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Document Type }
    
        { [{E44FA989-B4F8-466B-8EF4-C36F2A288803}];2 ;OrderDate           ;Element ;Field   ;
                                                      DataType=Date;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Order Date }
    
        { [{C65563FE-70C6-4A8F-B26D-0E7AC2C36E75}];2 ;PostingDate         ;Element ;Field   ;
                                                      DataType=Date;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Posting Date }
    
        { [{0A73F316-16B0-41A4-A9D9-7CDBC1CB1B5C}];2 ;ShortcutDimension   ;Element ;Field   ;
                                                      DataType=Code;
                                                      FieldValidate=No;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Shortcut Dimension 1 Code }
    
        { [{70D43C68-49D9-4283-B1C4-516B06BCC9F4}];2 ;LocationCode        ;Element ;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Location Code }
    
        { [{217A4928-6AC0-4785-B7A0-675A36A2FFA0}];2 ;PaymentMethod       ;Element ;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Payment Method Code }
    
        { [{870B28DE-6EA3-4E64-97B2-27E60FEA4AB7}];2 ;SellToCustomerNo    ;Element ;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Sell-to Customer No. }
    
        { [{8435B66E-785B-47A6-88C9-36B49A5B5637}];2 ;BillToCustomerNo    ;Element ;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Header>::Bill-to Customer No. }
    
        { [{AFB27989-1518-4B07-9204-8DB625F82A6A}];2 ;SalesLine           ;Element ;Text     }
    
        { [{CE546A14-1692-49F7-8B43-E035030655BD}];3 ;Line                ;Element ;Table   ;
                                                      VariableName=<Sales Line>;
                                                      SourceTable=Table37;
                                                      LinkFields=Field3=FIELD(Field3);
                                                      LinkTable=<Sales Header> }
    
        { [{268B06A7-60D1-498C-BCFD-C94C37220260}];4 ;DocumentType        ;Element ;Field   ;
                                                      DataType=Option;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Line>::Document Type }
    
        { [{69A5173A-DC42-40FD-96D2-BADA56D03866}];4 ;LineNo              ;Element ;Field   ;
                                                      DataType=Integer;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Line>::Line No. }
    
        { [{A2A19F0B-6899-4005-A6E3-F4111BB41299}];4 ;Type                ;Element ;Field   ;
                                                      DataType=Option;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Line>::Type }
    
        { [{AF104E84-12D3-4C0E-B7B7-6F1C283B7948}];4 ;ItemNo              ;Element ;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Line>::No. }
    
        { [{27537A3B-78CB-4445-A9D4-B51FCB0C56A8}];4 ;LocationCode        ;Element ;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Line>::Location Code }
    
        { [{ACECA638-8D9E-4ED7-A1B7-2B2BD99563C2}];4 ;Quantity            ;Element ;Field   ;
                                                      DataType=Decimal;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Line>::Quantity }
    
        { [{B2A535C3-3BC3-47B2-89D9-22F78E372A00}];4 ;SellToCustomerNo    ;Element ;Field   ;
                                                      DataType=Code;
                                                      AutoCalcField=No;
                                                      SourceField=<Sales Line>::Sell-to Customer No. }
    
      }
      EVENTS
      {
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    

    and Codeunit
    OBJECT Codeunit 123456781 restaurantXMLportImport
    {
      OBJECT-PROPERTIES
      {
        Date=22.03.11;
        Time=[ 2:28:51];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=BEGIN
                IF EXISTS('C:\objednavka.xml') THEN BEGIN
                  TestFile.OPEN('C:\objednavka.xml');
                  TestFile.CREATEINSTREAM(TestStream);
                  XMLPORT.IMPORT(123456789, TestStream);
                  TestFile.CLOSE;
    	      ERASE('C:\objednavka.xml');
                  MESSAGE('XML Import Complete.');
                END;
              END;
    
      }
      CODE
      {
        VAR
          TestFile@1000000000 : File;
          TestStream@1000000001 : InStream;
    
        BEGIN
        END.
      }
    }
    
  • kinekine Member Posts: 12,562
    As I wrote, the customer no. is assigned after you assign these two fields. In OnValidate of the field "Sell-to Customer No." is code, whcih overwrite these values by values fro the customer card... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matiqmatiq Member Posts: 8
    thank you very much, it's working :)
  • kinekine Member Posts: 12,562
    I hope that you have changed the order of the fields in import, not that you disabled the code in the OnValidate... :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matiqmatiq Member Posts: 8
    yes, i changed order :)
  • kinekine Member Posts: 12,562
    :thumbsup: Just for other random readers...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.