web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

XmlPort import information from csv file to current sales order

(0) ShareShare
ReportReport
Posted on by 20

Hello,

I am new at Nav, so maybe You can help me. (Also sorry for my english)

I am using NAV 2013 R2.

I am importing data from csv file to sales order, which one already exists, when I am in that order, I click action, which one imports additional information to sales header and imports new sales lines from that file.

My file looks like this:

T072478;left 2pcs;T

11114094;Door UA02-96, L shape;22;1,15; ;
11114093;DoorUA02-128, L shape;16;1,38; ;

In first line is information, which one must be in sales header: Reference;Comment;Boolean(True/False)

Second line is empty

In third line and so on is information about Sales lines: Item No;Description;Quantity;Amount;VariantCode;LocationCode

I wrote code in xmlport but something is wrong, when I am in Sales order and click action, that additional information did not apply to current order in which I am, I think it want create new order.

On that action trigger I just write:

ImportCSV.RUN;

On xmlport SalesHeader-Import::OnAfterInitRecord()

"Sales Line".SETRANGE("Sales Line"."Document Type","Sales Header"."Document Type");

"Sales Line".SETRANGE("Sales Line"."Document No.","Sales Header"."No.");

"Sales Header".GET("Sales Header"."Document Type","Sales Header"."No.");

Maybe I need function in the action trigger which one gets current sales order information?

I don't know if someone understands my problem, but I really need help.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    manjusree Profile Picture
    175 on at

    Hi,

    You can create an XMLport like this:-

    XMLport:-

    OBJECT XMLport 50000 ImportSales
    {
      OBJECT-PROPERTIES
      {
        Date=06-04-17;
        Time=10:37:04;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnPostXMLport=VAR
                        SalesHeader@1000000000 : Record 36;
                        SalesLine@1000000001 : Record 37;
                        LineNo@1000000002 : Integer;
                      BEGIN
                        IF TempSalesHeader.FINDFIRST THEN
                          IF SalesHeader.GET(DocType,DocNo) THEN BEGIN
                             SalesHeader."Other Reference":=TempSalesHeader."Other Reference";
                             SalesHeader.MODIFY;
                          END;
                        IF TempSalesLine.FINDLAST THEN BEGIN
                          SalesLine.RESET;
                          SalesLine.SETRANGE("Document Type",DocType);
                          SalesLine.SETRANGE("Document No.",DocNo);
                          IF SalesLine.FINDLAST THEN
                            LineNo:=SalesLine."Line No."+10000
                          ELSE
                            LineNo:=10000;
                          SalesLine.RESET;
                          SalesLine.INIT;
                          SalesLine.COPY(TempSalesLine);
                          SalesLine."Document Type":=DocType;
                          SalesLine."Document No.":=DocNo;
                          SalesLine."Line No.":=LineNo;
                          SalesLine.INSERT;
                        END;
                      END;

        Format=Variable Text;
        FieldDelimiter=<None>;
        FieldSeparator=<TAB>;
      }
      ELEMENTS
      {
        { [{59761F91-2FCA-48C0-B596-9E8D68F2ABF3}];  ;Root                ;Element ;Text     }

        { [{433F741D-E487-49EE-9B5A-1DCAF7275888}];1 ;TempSalesHeader     ;Element ;Table   ;
                                                      VariableName=TempSalesHeader;
                                                      SourceTable=Table36;
                                                      Temporary=Yes;
                                                      Import::OnAfterInitRecord=VAR
                                                                                  SalesHeaderRec@1000000000 : Record 36;
                                                                                BEGIN
                                                                                END;

                                                      Import::OnBeforeModifyRecord=VAR
                                                                                     SalesHeaderRec@1000000000 : Record 36;
                                                                                   BEGIN
                                                                                   END;
                                                                                    }

        { [{61277C52-F1B8-49B0-A3D2-8A2C4F4BA737}];2 ;OtherRef            ;Element ;Field   ;
                                                      DataType=Code;
                                                      SourceField=TempSalesHeader::Other Reference }

        { [{72F00AD4-ACC4-4EBA-95F8-A956475D9E3A}];1 ;TempSalesLine       ;Element ;Table   ;
                                                      VariableName=TempSalesLine;
                                                      SourceTable=Table37;
                                                      Temporary=Yes }

        { [{DC04B9CF-F061-48A8-AA21-F585BFBB8C4E}];2 ;No                  ;Element ;Field   ;
                                                      DataType=Code;
                                                      SourceField=TempSalesLine::No. }

        { [{F35D90DF-9315-4F95-A777-AB1BF2A3CF8C}];2 ;Description         ;Element ;Field   ;
                                                      DataType=Text;
                                                      SourceField=TempSalesLine::Description }

      }
      EVENTS
      {
      }
      REQUESTPAGE
      {
        PROPERTIES
        {
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          DocNo@1000000000 : Code[20];
          DocType@1000000001 : 'Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order';
          test@1000000002 : Text[100];

        PROCEDURE SetDocNo@1000000000(DocumentType@1000000001 : 'Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order';DocumentNo@1000000000 : Code[20]);
        BEGIN
          DocType:=DocumentType;
          DocNo:=DocumentNo;
          TempSalesHeader.SETRANGE("Document Type",DocType);
          TempSalesHeader.SETRANGE("No.",DocNo);
        END;

        BEGIN
        END.
      }
    }

    ========================================

    Please call SetDocNo function before calling XMLport.RUN. Basically you should write below code in Action:-

    ImportCSV.SetDocNo("Document Type","No.");
    ImportCSV.RUN;

  • Suggested answer
    Rabin Profile Picture
    2,976 on at

    Hi,

    Here on this community, you can get help from different experts in the field, but you have to follow some guidelines. First make your issue short and to the point. And do not expect the full solution, this is what you are supposed to do.

    So my suggestion is to find what issue are you getting, just make the question short so that most of the expert scanning through issue have time to read and comment. That is how you can also resolve the issue.

    [tag:BestOfLuck] With your code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans