Export from xml a list of values

RikarddoRikarddo Member Posts: 80
Hi!



I have a xmlport that export data using this code:

Ship-to Address - Export::OnPreXMLItem()

 CLEARALL();
 ltBusRel.RESET;
 ltBusRel.SETRANGE("Contact No.",ContactoNo);
 ltBusRel.SETRANGE("Business Relation Code",'CLI');
 IF ltBusRel.FINDFIRST THEN BEGIN
  ltcustomer.RESET;
  ltcustomer.SETRANGE("No.",ltBusRel."No.");
  IF ltcustomer.FIND('-') THEN BEGIN
    "Ship-to Address".RESET;
    "Ship-to Address".SETRANGE("Customer No.",ltcustomer."No.");
    IF "Ship-to Address".FINDSET THEN BEGIN
    REPEAT
        CodPostalEndEnv:="Ship-to Address"."Post Code";//+' - '+ltcustomer."Post Code";
        pesquisacontacto.SETTABLEVIEW("Ship-to Address");
    UNTIL "Ship-to Address".NEXT=0;
    END ELSE BEGIN
        CodPostalEndEnv:='';
        CodPostalEndEnv:=ltcustomer."Post Code";
    END;
  END;
 END;

But i have some problems


It only finds the first post code from table shipping address. How to run all the codes in the table and show them.

Second, if the customer has no shipping addresses then it will return the post code in the customer card ( not working)

How can i improve my code to get this working, or should i try this in other tag?



thanks for the help

Answers

  • RikarddoRikarddo Member Posts: 80
    edited 2018-06-21
    Tried this

    Put this Into OnPreXMLItem:
     CLEARALL();
     CodPostalEndEnv:=''; 
     ltBusRel.RESET;
     ltBusRel.SETRANGE("Contact No.",ContactoNo);
     ltBusRel.SETRANGE("Business Relation Code",'CLI');
     IF ltBusRel.FINDFIRST THEN BEGIN
      ltcustomer.RESET;
      ltcustomer.SETRANGE("No.",ltBusRel."No.");
      IF ltcustomer.FIND('-') THEN BEGIN
        CodPostalEndEnv:=ltcustomer."Post Code";
        "Ship-to Address".RESET;
        "Ship-to Address".SETRANGE("Customer No.",ltcustomer."No.");
      END;
     END;
    


    And Put this into "Ship-to Address" OnAfterGetRecord:
    CodPostalEndEnv:="Ship-to Address"."Post Code";//+' - '+ltcustomer."Post Code";
    pesquisacontacto.SETTABLEVIEW("Ship-to Address");
    

    For a customer that has no shipping addresses , the value returns null. It should return the customer Post Code in this case.

    For a customer that has shipping addresses it returns correctly the values from the table.


    Then moved all code from OnPreXMLItem to OnPreXMLPort trigger but it returns all the addresses of the table independently of the customer...

    Help?
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    What's wrong with hungarian notation exactly?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • RikarddoRikarddo Member Posts: 80
    edited 2018-06-25
    Really? Instead of helping, you criticize the way how code is inputed? Please save those criticisms for yourself
Sign In or Register to comment.