XMLport send Post Code plus Ship-to Adress

Rikarddo
Member Posts: 80
Hello all,
I'm building a XMLport that sends some information to our internal sofwtare, such as name of contact, address , post code etc..im getting difficulties on the post code.
The logic is, if the the contact is customer, then it returns by default the customer post code. If that customer has more than shipping address than it returns the customer post code and those shipping post codes.
If the contact is not customer it returns the contact post code.
Node Name Prefix Node Type Source Type Data Source
XMLPesquisaContacto Element Text <XMLPesquisaContacto>
ContactoNo Element Text <ContactoNo>
Contacto Element Table <Contact>(Contact)
No Element Field Contact::No.
CodPostal Element Field Contact::Post Code
CodPais Element Text <CodPais>
PaymtTerms Element Table <Payment Terms>(Payment Terms)
CodTerms Element Field Payment Terms::Code
Descricao Element Field Payment Terms::Description
Ship-toAddress Element Table <Ship-to Address>(Ship-to Address)
CodPostalEndEnv Element Text <CodPostalEndEnv>
This is for now the code i have
This is the code i'm trying to implement
But 'ive got errors if customer has only post code. If customer has shipping addresses then it return the first post code only repeatd n times.
I've managed to got working to payment terms.
Any help would be appreciated .
I'm building a XMLport that sends some information to our internal sofwtare, such as name of contact, address , post code etc..im getting difficulties on the post code.
The logic is, if the the contact is customer, then it returns by default the customer post code. If that customer has more than shipping address than it returns the customer post code and those shipping post codes.
If the contact is not customer it returns the contact post code.
Node Name Prefix Node Type Source Type Data Source
XMLPesquisaContacto Element Text <XMLPesquisaContacto>
ContactoNo Element Text <ContactoNo>
Contacto Element Table <Contact>(Contact)
No Element Field Contact::No.
CodPostal Element Field Contact::Post Code
CodPais Element Text <CodPais>
PaymtTerms Element Table <Payment Terms>(Payment Terms)
CodTerms Element Field Payment Terms::Code
Descricao Element Field Payment Terms::Description
Ship-toAddress Element Table <Ship-to Address>(Ship-to Address)
CodPostalEndEnv Element Text <CodPostalEndEnv>
This is for now the code i have
//{código original CLEARALL(); CodPais:=''; ltBusRel.RESET; ltBusRel.SETRANGE("Contact No.",ContactoNo); ltBusRel.SETRANGE("Business Relation Code",'CLI'); IF ltBusRel.FINDFIRST THEN BEGIN Contact.RESET; Contact.SETRANGE("No.",ltBusRel."Contact No."); IF Contact.FIND('-') THEN IF Contact."Country/Region Code"<> '' THEN BEGIN CodPais:=Contact."Country/Region Code"; CodPostalEndEnv:=Contact."Post Code"; pesquisacontacto.SETTABLEVIEW(Contact); END ELSE BEGIN CodPais:='PT'; pesquisacontacto.SETTABLEVIEW(Contact); END; END; //}
This is the code i'm trying to implement
{ CLEARALL(); CodPostalEndEnv:=Contact."Post Code"; 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.",ltBusRel."No."); IF "Ship-to Address".FIND('-') THEN BEGIN REPEAT CodPostalEndEnv:="Ship-to Address"."Post Code"; pesquisacontacto.SETTABLEVIEW("Ship-to Address"); UNTIL "Ship-to Address".NEXT=0; END ELSE BEGIN CodPostalEndEnv:=Contact."Post Code"; pesquisacontacto.SETTABLEVIEW(Contact); END; END; END ELSE BEGIN ltBusRel.RESET; ltBusRel.SETRANGE("Contact No.",ContactoNo); IF ltBusRel.FINDFIRST THEN BEGIN CodPostalEndEnv:=Contact."Post Code"; pesquisacontacto.SETTABLEVIEW(Contact); END; END;
But 'ive got errors if customer has only post code. If customer has shipping addresses then it return the first post code only repeatd n times.
I've managed to got working to payment terms.
Payment Terms - Export::OnPreXMLItem() CLEARALL(); CodPais:=''; ltBusRel.RESET; ltBusRel.SETRANGE("Contact No.",ContactoNo); ltBusRel.SETRANGE("Business Relation Code",'CLI'); IF ltBusRel.FINDFIRST THEN BEGIN Contact.RESET; Contact.SETRANGE("No.",ltBusRel."Contact No."); IF Contact.FIND('-') THEN IF Contact."Country/Region Code"<> '' THEN CodPais:=Contact."Country/Region Code" ELSE BEGIN CodPais:='PT'; pesquisacontacto.SETTABLEVIEW(Contact); END; ltcustomer.RESET; ltcustomer.SETRANGE("No.",ltBusRel."No."); IF ltcustomer.FIND('-') THEN BEGIN "Payment Terms".RESET; "Payment Terms".SETCURRENTKEY(Code); "Payment Terms".ASCENDING(FALSE); "Payment Terms".SETFILTER(Code,'%1|%2',ltcustomer."Payment Terms Code",'A'); IF "Payment Terms".FIND('-') THEN BEGIN pesquisacontacto.SETTABLEVIEW("Payment Terms"); END; END ELSE BEGIN CodPais:='PT'; "Payment Terms".RESET; "Payment Terms".SETFILTER(Code,'%1','A'); pesquisacontacto.SETTABLEVIEW("Payment Terms"); END; END;
Any help would be appreciated .
0
Best Answer
-
If someone someday has the same problem, here it is the solution:
Node Name Prefix Node Type Source Type Data Source
XMLPesquisaContacto Element Text <XMLPesquisaContacto>
ContactoNo Element Text <ContactoNo>
Contacto Element Table <Contact>(Contact)
No Element Field Contact::No.
CodPostal Element Field Contact::Post Code
CodPais Element Text <CodPais>
PaymtTerms Element Table <Payment Terms>(Payment Terms)
CodTerms Element Field Payment Terms::Code
Descricao Element Field Payment Terms::Description
Ship-toAddress Element Table <Ship-to Address>(Ship-to Address)
CodPostalEndEnv Element Text <CodPostalEndEnv>
Tip: Ship-toAddress temporaryContact - Export::OnPreXMLItem() CLEARALL(); CodPais:=''; ltBusRel.RESET; ltBusRel.SETRANGE("Contact No.",ContactoNo); ltBusRel.SETRANGE("Business Relation Code",'CLI'); IF ltBusRel.FINDFIRST THEN BEGIN Contact.RESET; Contact.SETRANGE("No.",ltBusRel."Contact No."); IF Contact.FIND('-') THEN IF Contact."Country/Region Code"<> '' THEN CodPais:=Contact."Country/Region Code" ELSE BEGIN CodPais:='PT'; pesquisacontacto.SETTABLEVIEW(Contact); END; ltcustomer.RESET; ltcustomer.SETRANGE("No.",ltBusRel."No."); IF ltcustomer.FIND('-') THEN BEGIN "Ship-to Address"."Post Code":=ltcustomer."Post Code"; "Ship-to Address".INSERT; ShiptoAddress.RESET; ShiptoAddress.SETRANGE("Customer No.",ltcustomer."No."); ShiptoAddress.SETCURRENTKEY("Customer No.",Code); IF ShiptoAddress.FINDFIRST THEN BEGIN IF ShiptoAddress.Code<>'' THEN BEGIN REPEAT "Ship-to Address":=ShiptoAddress; "Ship-to Address".INSERT; UNTIL ShiptoAddress.NEXT=0; END; END ELSE BEGIN "Ship-to Address"."Post Code":=Contact."Post Code"; "Ship-to Address".MODIFY; END; END; END ELSE BEGIN Contact.RESET; Contact.SETRANGE("No.",ContactoNo); IF Contact.FIND('-') THEN BEGIN CodPais:='PT'; "Ship-to Address"."Post Code":=Contact."Post Code"; "Ship-to Address".INSERT; pesquisacontacto.SETTABLEVIEW(Contact); END; END;
0
Answers
-
If someone someday has the same problem, here it is the solution:
Node Name Prefix Node Type Source Type Data Source
XMLPesquisaContacto Element Text <XMLPesquisaContacto>
ContactoNo Element Text <ContactoNo>
Contacto Element Table <Contact>(Contact)
No Element Field Contact::No.
CodPostal Element Field Contact::Post Code
CodPais Element Text <CodPais>
PaymtTerms Element Table <Payment Terms>(Payment Terms)
CodTerms Element Field Payment Terms::Code
Descricao Element Field Payment Terms::Description
Ship-toAddress Element Table <Ship-to Address>(Ship-to Address)
CodPostalEndEnv Element Text <CodPostalEndEnv>
Tip: Ship-toAddress temporaryContact - Export::OnPreXMLItem() CLEARALL(); CodPais:=''; ltBusRel.RESET; ltBusRel.SETRANGE("Contact No.",ContactoNo); ltBusRel.SETRANGE("Business Relation Code",'CLI'); IF ltBusRel.FINDFIRST THEN BEGIN Contact.RESET; Contact.SETRANGE("No.",ltBusRel."Contact No."); IF Contact.FIND('-') THEN IF Contact."Country/Region Code"<> '' THEN CodPais:=Contact."Country/Region Code" ELSE BEGIN CodPais:='PT'; pesquisacontacto.SETTABLEVIEW(Contact); END; ltcustomer.RESET; ltcustomer.SETRANGE("No.",ltBusRel."No."); IF ltcustomer.FIND('-') THEN BEGIN "Ship-to Address"."Post Code":=ltcustomer."Post Code"; "Ship-to Address".INSERT; ShiptoAddress.RESET; ShiptoAddress.SETRANGE("Customer No.",ltcustomer."No."); ShiptoAddress.SETCURRENTKEY("Customer No.",Code); IF ShiptoAddress.FINDFIRST THEN BEGIN IF ShiptoAddress.Code<>'' THEN BEGIN REPEAT "Ship-to Address":=ShiptoAddress; "Ship-to Address".INSERT; UNTIL ShiptoAddress.NEXT=0; END; END ELSE BEGIN "Ship-to Address"."Post Code":=Contact."Post Code"; "Ship-to Address".MODIFY; END; END; END ELSE BEGIN Contact.RESET; Contact.SETRANGE("No.",ContactoNo); IF Contact.FIND('-') THEN BEGIN CodPais:='PT'; "Ship-to Address"."Post Code":=Contact."Post Code"; "Ship-to Address".INSERT; pesquisacontacto.SETTABLEVIEW(Contact); END; END;
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