Hello,
I export item records from a Nav database to another Nav database using xmlports. Every 10 minutes all the modified items are exported to xml files using a NAS service. Everything works correct expect for the following fact: if a user is modifying an item and in the meantime the Nas service triggers (starts exporting the item recs) I receive the error that I attached.
Consequently some modifications are lost and of course the error is not nice to receive during modifications.
Can someone give me a suggestion on how to avoid the issue. At this moment we are bypassing the problem with a button on the form that the user must push to export the recs to xmlports: but as you can deduct our customer wants something automatic.
Thank you so much
0
Comments
If on importing, yes, of course, you are changing it and the user viewed the previous version of the record...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
thanks for your response, well, as I explained in my first message I have the problem while exporting nav items to xmlport, and yes the problem occurs just when exporting the info (by nas) and the user is modifying the rec. When yiu say Tablelock are you talking about "LockTable"? If so I tried using it just before calling the xmlport exporting as you can se in the following code lines:
IF lRecCompany."Sync Output Xml Folder" <> '' THEN
BEGIN
// -- ITEM
lRecItem.LOCKTABLE(TRUE);
lRecItem.SETCURRENTKEY(ToSync);
lRecItem.SETRANGE(ToSync, TRUE);
IF lRecItem.FINDSET(TRUE,TRUE) THEN
REPEAT
lRecItem2 := lRecItem;
lRecRecRef.OPEN(DATABASE::Item);
lRecRecRef.GETTABLE(lRecItem);
CreateXmlFile(lRecRecRef);
lRecRecRef.CLOSE;
UNTIL lRecItem.NEXT = 0;
where the function CreateXmlFile(lRecRecRef) is a simple procedure that exports the rec to xmlport:
......
DATABASE::Item:
BEGIN
iRecRecRef.SETTABLE(lRecItem);
IF STRPOS(lTxtNewFileName,'__') = 0 THEN
IF lFilNewFile.CREATE(lTxtNewFileName) THEN
BEGIN
lFilNewFile.CREATEOUTSTREAM(OStr);
lXmlItemSyncEVC.SetItem(lRecItem);
lXmlItemSyncEVC.SETDESTINATION(OStr);
lXmlItemSyncEVC.EXPORT;
lFilNewFile.CLOSE;
EXIT(TRUE);
END;
END;
.....
but the error still occurs
Please some other suggestion
Thanks
In you case, you will gate hundreds and hundreds XML files, one for each item.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
yes I know that i get an xml file for each record: it's a requirement for historical purposes, but we are trying to convince our cust to put in a single xml port all the modified items.
Said this we are not focusing on the real problem dued to exporting to xml during user modifications. In fact as you suggest in your last response "Why not use just xmlport over the Item table and run it once to export all what you need into the XML file?" OK this will create one xml file for all my modifed items but if nas executes such functionality during a user is modifying the item table I receive the error and the last modifciations are lost.
Any further suggestions?
Thank you very much
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.