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.
0
Comments
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?
I believe it's one of your validation that causes the issue.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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.
I must learn how to insert code in posts.
This is code from Debugger:
In my upper post I simply copy_pasted it from Object Designer. But it doesn't look readable.
Also could you paste the CallStack.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
My guess your xmlport is creating contacts.
I suggest that you add the following code to xmlport
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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.
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):
And I inserted as you had suggested code in the codeunit of the xmlport:
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I'm sorry, I didn't quite understand, what you mean :oops:
Would you, please, explain it in some details.
Sorry!
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.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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()
I use codeunit in report because I can't create standalone codeunit. I have no 7200 granule Application Builder
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.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/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.
XML ports can only insert records. You have to write code to manually update if customer already exists.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
:-k
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n