Hi all,
I have created a xmlport to import customer records to navision. for this the first time when i import the file , the customer need to be inserted and from the next time , it needs to be updated. So I have written the code as below in onafterimport trigger in xmlport.
IF NOT CustRec.GET(Customer."No.") THEN BEGIN
Customer."No." := Customer."No.";
Customer.Name := Customer.Name;
Customer."Search Name" := Customer."Search Name";
Customer."Name 2" := Customer."Name 2";
Customer.Address := Customer.Address;
Customer.MODIFY(TRUE);
END
ELSE
Customer.INSERT(TRUE);
but still I am getting the error customer record already exists.
If anyone knows the solution for the above mentioned scenario, kindly let me know.
Thanks in advance.
Regards,
chandru.
0
Comments
Check if there is any record with these values of primary key, if yes then assign the field values from the variables and at the end write MODIFY
Or
If record doesn't exist then assign values to field from these variable and write INSERT.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
So if theres no Record then you will modify the non existing record ?
And if there is a Record then you will insert a Blank one ?
Your Code says that ...
just remove the NOT in your IF-Clause and youll be fine !
€: watch mohanas post above for a cleaner solution
Even if i remoce the not , still I am getting a error as follows.
The XML Parser return the following fatal error:
A document must contain exactly one root element.
Line Number = 9 Column Number = 10
If you have any idea, kindly let me know.
Thanks in advance.
Regards,
chandru.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav