Hello all. I've searched these forums hard for an answer to my problem but I could find the answer to one little detail with my problem.
The Setup:
I have an XMLPort that reads in an XML doc that has a duplicate entry. In my XMLport I have one table which is a "Temporary" table. On the OnBeforeInsertRecord trigger of the table I search the record to see if it exists. I am able to successfully locate the existing record and I call a CurrXMLport.SKIP and the CurrXMLport.SKIP does execute but Navision tries to insert the record anyway. Any ideas as to why it inserts regardless of the CurrXMLport.SKIP? If not, how can I make it so that it doesn't insert.
Below is code from my OnBeforeInsertRecord trigger.
IF Rec.GET(field.variable,field.variable,field.variable) THEN BEGIN
MESSAGE('THIS RECORD ALREADY EXISTS');
currXMLport.SKIP;
END;
I can see the dialog pop up when a duplicate is found and the skip executes but then I get a Navision error that the entry already exists and the program just dies ](*,) .
Any ideas?
Thanks!
0
Answers
RIS Plus, LLC
You have to do this on the Import::OnAfterInsertRecord() trigger of
the temp table record.
And if you insert more then 1 record you have to loop your temp
table plus the property MaxOccurs must be Unbounded.
In this case i will check if the record allready exists not using the primarykey
of the table but the "external documetn No." because that's the
unique number of the customers Document.
TempHeader - Import::OnAfterInsertRecord()
CLEAR(recHeader);
recHeader.SETCURRENTKEY("External Document No.");
recHeader.SETRANGE("External Document No.",TempHeader."External Document No.");
IF NOT recHeader.FIND('-') THEN BEGIN
recHeader.TRANSFERFIELDS(TempHeader);
IF recHeader.INSERT(TRUE) THEN BEGIN
...
...
...
END ELSE BEGIN
// Error Order Header not inserted
END;
END ELSE BEGIN
// Error Order already Exists
END;
Maybe something like this ?
You have to do this on the Import::OnAfterInsertRecord() trigger of
the temp table record.
And if you insert more then 1 record you have to loop your temp
table plus the property MaxOccurs must be Unbounded.
In this case i will check if the record allready exists not using the primarykey
of the table but in this case "the external documetn No." because that's the
unique number of the customers Document.
TempHeader - Import::OnAfterInsertRecord()
CLEAR(recHeader);
recHeader.SETCURRENTKEY("External Document No.");
recHeader.SETRANGE("External Document No.",TempHeader."External Document No.");
IF NOT recHeader.FIND('-') THEN BEGIN
recHeader.TRANSFERFIELDS(TempHeader);
IF recHeader.INSERT(TRUE) THEN BEGIN
...
...
...
END ELSE BEGIN
// Error Order Header not inserted
END;
END ELSE BEGIN
// Error Order already Exists
END;
CLEAR("TempHeader);
And if this is not what you are looking for, you can always
base your import on a integer table en use elements with source type text.
And if this is not what you are looking for, you can always
base your import on a integer table en use elements with source type text.