XML import Customer list problem

remark
Member Posts: 122
I try to import a customer list via XML port to Table 18 Customer and get a following massage:
"Customer K00110 has already Contact Business Relation with Contact CT00170"
and no lines are put in the Customer Table.
There isn't both Customer K00110 and Contact CT00170 in the database.
Please, help me to solve this.
"Customer K00110 has already Contact Business Relation with Contact CT00170"
and no lines are put in the Customer Table.
There isn't both Customer K00110 and Contact CT00170 in the database.
Please, help me to solve this.
0
Comments
-
After multiple attempts it seems that it's impossible insert even one line with the only field filled ("No.") because of some link with the table Contacts.
The same XML port inserts lines seccessfully in another table, which were created for these testing purposes.
Is it impossible to import Customer list with the help of XML port altogether?0 -
Could you post your xmlport and xml file example.
I believe it's one of your validation that causes the issue.0 -
This is the structure of the XML port:
TagName TagType SourceType DataSource
Customers Element Text <Customers>
Customer Element Table <Customer>(Customer)
No. Element Field <Customer>::No.
Name Element Field <Customer>::Name
SearchName Element Field <Customer>::Search Name
Address Element Field <Customer>::Address
City Element Field <Customer>::City
PostCode Element Field <Customer>::Post Code
This is a sample of some lines from XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customers>
<Customer>
<No.>K00050</No.>
<Name>SomeName</Name>
<SearchName>SOMENAME</SearchName>
<Address>SomeAddress</Address>
<City>SomeCity</City>
<PostCode>109000</PostCode>
</Customer>
<Customer>
<No.>K00060</No.>
<Name>SomeName2</Name>
<SearchName>SOMENAME2</SearchName>
<Address>SomeAddress2</Address>
<City>SomeCity</City>
<PostCode>109000</PostCode>
</Customer>
</Customers>
This is code from Dubugger. These lines are from OnInsert trigger of Table 5054 Contact Business Relation.
OnInsert()
IF "No." <> '' THEN BEGIN
ContBusRel.SETRANGE("Contact No.","Contact No.");
ContBusRel.SETRANGE("Link to Table","Link to Table");
IF ContBusRel.FIND('-') THEN
ERROR(
Text000,
Cont.TABLECAPTION,"Contact No.",TABLECAPTION,"Link to Table",ContBusRel."No.");
ContBusRel.RESET;
ContBusRel.SETCURRENTKEY("Link to Table","No.");
ContBusRel.SETRANGE("Link to Table","Link to Table");
ContBusRel.SETRANGE("No.","No.");
IF ContBusRel.FIND('-') THEN
ERROR(
Text000,
"Link to Table","No.",TABLECAPTION,Cont.TABLECAPTION,ContBusRel."Contact No.");
Here it stops with that error. ](*,)
The XML file is large, so I've made a simplified extract from it in order that this post could be readable.0 -
Sorry, after posting all the indents are lost and the structure of port became different.
I must learn how to insert code in posts.0 -
Second attempt.
This is code from Debugger:OnInsert() IF "No." <> '' THEN BEGIN ContBusRel.SETRANGE("Contact No.","Contact No."); ContBusRel.SETRANGE("Link to Table","Link to Table"); IF ContBusRel.FIND('-') THEN ERROR( Text000, Cont.TABLECAPTION,"Contact No.",TABLECAPTION,"Link to Table",ContBusRel."No."); ContBusRel.RESET; ContBusRel.SETCURRENTKEY("Link to Table","No."); ContBusRel.SETRANGE("Link to Table","Link to Table"); ContBusRel.SETRANGE("No.","No."); IF ContBusRel.FIND('-') THEN ERROR( Text000, "Link to Table","No.",TABLECAPTION,Cont.TABLECAPTION,ContBusRel."Contact No.");
0 -
Well, this is XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Customers> <Customer> <No.>K00050</No.> <Name>SomeName</Name> <SearchName>SOMENAME</SearchName> <Address>SomeAddress</Address> <City>SomeCity</City> <PostCode>109000</PostCode> </Customer> <Customer> <No.>K00060</No.> <Name>SomeName2</Name> <SearchName>SOMENAME2</SearchName> <Address>SomeAddress2</Address> <City>SomeCity</City> <PostCode>109000</PostCode> </Customer> </Customers>
0 -
What about XML port I need some advise how I could post it.
In my upper post I simply copy_pasted it from Object Designer. But it doesn't look readable.0 -
export it to text and then paste it.
Also could you paste the CallStack.0 -
I created the xmlport and used your xml to import it without any issues.
My guess your xmlport is creating contacts.
I suggest that you add the following code to xmlportCustomer - Import::OnBeforeInsertRecord() Customer.SetInsertFromContact(TRUE);
0 -
ara3n wrote:I created the xmlport and used your xml to import it without any issues.
My guess your xmlport is creating contacts.
I suggest that you add the following code to xmlportCustomer - Import::OnBeforeInsertRecord() Customer.SetInsertFromContact(TRUE);
I tried, but it didn't work.
Concerning xmlport creating contacts, the fact is records are created in tables 5054 Contact Business Relation and 5050 Contact not by xmlport only, this happens always when we add new customer by hand.0 -
ara3n wrote:export it to text and then paste it.
Also could you paste the CallStack.
Unfortunatley, I can't export xmlport in text format, only in .fob. I have such choice in export window, but after trying it I get system message that I can't do it. It connected maybe with licensing issues.
My code for running xmlport following (I use codeunit in report because I can't create standalone codeunit. I have no 7200 granule Application Builder):Customer - OnAfterGetRecord() IF NOT EXISTS('C:\XML_Customer.xml') THEN ERROR('XML Document File Does Not Exists'); TestFile.OPEN('C:\XML_Customer.xml'); TestFile.CREATEINSTREAM(TestStream); XMLPORT.IMPORT(50001,TestStream); TestFile.CLOSE; MESSAGE('XML Customer Import Complete.');
And I inserted as you had suggested code in the codeunit of the xmlport:Customer - Import::OnBeforeInsertRecord() Customer.SetInsertFromContact(TRUE);
0 -
Can you write the callstack when it errors out?0
-
call stack is a special stack which stores information about the active subroutines of a computer program. (The active subroutines are those which have been called but have not yet completed execution by returning.
Basically a list of triggers until it reaches the error.
It tells you how it calls the trigger and gives you error.
It's a separate window in debugger. Over over the 4 windows in debugger and one of it is the calls stack.0 -
Thank you!
Here it is:
Table 5054 Contact Business Relation\OnInsert()
Codeunit 5056 CustCont-Update\InsertNewContact(Cust,LocalCall)
Codeunit 5056 CustCont-Update\OnInsert(Cust)
Table 18 Customer\OnInsert()
Report 50001 XMLrun\Customer - OnAfterGetRecord()0 -
Report 50001 "XMLrun" is here for only purpose to run XMLport.
I use codeunit in report because I can't create standalone codeunit. I have no 7200 granule Application Builder0 -
Try
Customer - Import::OnAfterInitRecord()
Customer.SetInsertFromContact(TRUE);
in xml port;
if it doesn't work, try and set in "Relationship Management Setup" the field
"Bus. Rel. Code for Customers" to blank.0 -
Thank you, ara3n!
Yes, it helped to solve problem with the Contacts, but now yet another problem appeared:
After I run XMLport, I get a message "XML Customer Import Complete", then, after it is closed I get another message: "Customer No. XXX exists already". After that I see, that nothing is imported in Customer Table.
"No. XXX" is the first "No." in the XMLport. And such number doesn't exist in Customer Table neither before importing no after it.
In this case debugger doesn't show any error.0 -
Does the customer exists?
XML ports can only insert records. You have to write code to manually update if customer already exists.0 -
Customer doesn't exist.
:-k0 -
Your xmlport works. Your xml file probably has the same customer number twice in there.0
-
Ara3n, Thank you very much for your patience.
My XMLport really works.
The problem was caused by the way in which I run my Report 50001 "XMLrun" with the xml running code.
Only your assurance that everything with my XMLport is OK helped me to find the real cause. I was looking for bug in the wrong place.
Thank you for leading me through this way!0 -
You are welcome, and thanks for your patience0
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