How to delete catalog items using Data Processor

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

I imported about 6000 items from am excel sheet into one catalog. Now I want to delete them from the list, but every time I am trying to mark all items at once, the system asks me something like:

1000 rows selected. Continue? If I press ok, it lasts very long. So I have to click "no" and next time select the next 1000 rows again. If I show this solution my customer, he will not like it at all.

So I think if I make it using data processor it will be better. But I have no idea how shoud I implement it (write code).

Could somebody help me?

Thanks in advance!

 
#2
People who like this:1Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Lioudmila!

You need to create a query with result processing, get object and set deletion mark for this item or delete directly. You can right-click somewhere in the module and select this option from the context menu.

Code
   Query = New Query;
   Query.Text = 
      "SELECT
      |   Items.Ref
      |FROM
      |   Catalog.Items AS Items
      |WHERE
      |   NOT Items.DeletionMark";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
   While SelectionDetailRecords.Next() Do
      CurObject = SelectionDetailRecords.Ref.GetObject();
      CurObject.DeletionMark = True;
      CurObject.Write();
      // CurObject.Delete(); // Dangerous
   EndDo;

Download query.png (25.87 KB)
 
#3
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

Thanks a lot, Timofey! It was really very easy and it works! :)

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.