I am working in Navision 3.6 (SQL Server Version). Our customer has a list of 14,000 obsolete items that they want to delete due to lack of activity.
I want to read this list and delete the corresponding record from Navision. I understand that you cannot delete from a dataport so I am passing the record to a processing report where the delete attempt is made. I end the delete in the report with a COMMIT and, through debugger, the record appears deleted. However, when testing the process with say, 10 records, only the last record is actually deleted. I have added commit statements to the dataport, as well, but am at a loss.
I am contemplating adding a field to the Item table where the dataport will mark the item for deletion. Then, separately, run the report to delete only those marked items but that seems unnecessary.
Below are the current code snippets I am working with:
* the dataport after validations to qualify the record are completed:
// Delete Customer Record if validation tests have been successful
VarItemDeleted := ItemNo;
GET(ItemNo);
ItemRec.COPY(Item);
ItemRec.SETRANGE("No.", ItemRec."No.");
REPORT.RUN(50135,FALSE,FALSE,ItemRec); //<-- pass rec to report.
COMMIT;
. . .
* the report step where deletion of passed record is executed:
OnAfterGetRecord()
DELETE(TRUE);
COMMIT;
Any suggestions on why this does not work or what to do to make it work would be greatly appreciated?
0
Comments
If you are doing this then why not just go to the Item Table.
Filter on this field.
Select All.
Hit the Delete Button.
:-k
Perhaps the criteria used to "Mark" the obsolete items in the report can be used on the item table directly w/ filters then you don't even need that field.
I'm not understanding the DATAPORT part, unless your trying to export a list of these killed items. Even then you could copy & paste into excel from the item table once you have placed your filters.
Make sure you have a backup before deleteing 14000 items - you never know when you might need that info back.
PS: I believe we had a discussion about items like this and they do get in the way sometimes. I think it was TheMave that mentioned creating a Visible boolean field along with using the "blocked" field to simply hide away these items by adding this field filter to a few forms, therefore not doing any drastic database changes.
http://www.BiloBeauty.com
http://www.autismspeaks.org
your assigning ItemNo before you get it? Not sure what this code is trying to do. I would assume you simply use the dataitem of ITEM for your report and as it runs and meets the criteria it would delete the record.
you could always set the DataItemTableView with all your criteria so no filters need to be manually entered
http://www.BiloBeauty.com
http://www.autismspeaks.org
So, when the dataport reads in the item number WIDGET, it validates the record, then passes that Item record for WIDGET to the report.
The report then deletes that record.
The dataport then reads the next record...
The dataport is being used primarily to read the external text file. But, yes, an Excel output is created listing items deleted and any exceptions found (i.e. existing open sales lines, etc.).
I was just looking for a way to examine items from a provided list and delete those items. The main goal is to automate the process and keep IT out of doing this repeatedly in the future and give select users the ability to remove the junk that unfortunately gets imported or entered. I just wanted to use existing methods rather than add another field to a table.
WARNING..
THIS DATAPORT ONLY DELETES THE RECORD OFF THE ITEM TABLE. YOU WILL HAVE TO ADD ADDITIONAL CODE TO DELETE THE RELATED TABLES SUCH AS A PRICE TABLE OR VARIANT TABLE OR WHATEVER OTHER TABLES YOU WANT TO CLEAR!! THE OnDelete Trigger is not fired by this dataport. you should review the OnDelete Trigger of the item table & ADD that code to this DATAPORT.The dataport would be something like this - add additional code if you need to
http://savatage99.googlepages.com/Delet ... taport.txt
http://www.BiloBeauty.com
http://www.autismspeaks.org
All this needs to be cleared to.
http://www.BiloBeauty.com
http://www.autismspeaks.org
On the main forms & lists add "Not Visible":FALSE to the DataItemTableView
Not a big fan of deletion unless we're talking NO ENTIRES WHATSOEVER for that item. But even if you do go this route you could always filter on "Not Visible"=TRUE and hit the delete button - then the OnDelete Trigger with all the proper code will be executed as it should be.
I understand sometimes it needs to be done.
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org