Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > How to delete register records by date?

Forum

Search UsersRules
How to delete register records by date?
#1
Active user
Points:: 0
Joined:: Jul 3, 2013

Thanks Just came and Active user!
I need delete some record with "Period" on a day ( example Current Date = Jul 05, 2014 15:51 PM)
But Period Attributes have type as datetime, then when uses your way with method: "RecordSet.Filter.Period.Set(CurrentDate())" and method "RecordSet.Read()"; then I get the results "RecordSet.Count()" return =0.
Because special records write on about time form Jul 05, 2014 08:30 AM to Jul 05, 2014 13:30 PM; then
method "Filter.Period.Set(CurrentDate())" not available. I can not set parameters to exact time every hour, every minute every second. and the fact that I can not always know exactly the time what the user recorded in the system and record write.
How another way allow me delete some record with "Period" between dateform and dateto.
Thank a lot! :(

Profile
#2
Active user
Points:: 0
Joined:: Sep 26, 2012

I can suggest 2 ways.

First you can do query to InformationRegister and then delete record with using RecordSet and Filter (Values of dimensions and also detailed value of Period for filter will be known after query)

Second way: use CreateRecordSet() and then read recordset but dont set filter on period (but maybe set another filters)
So you get all records in recordset and then you can process each record in a cycle and delete desired record

Profile
#3
Guest
Points::
Joined::

Hello, Hoang Minh Tri!
Thank you for joining 1C:Developer Network!

Filters here can use only Equal condition.
Try the following method, you can select dates of records and delete using record set each date:

Code
   Query = New Query;
   Query.Text = "SELECT DISTINCT
                |   Requests.Period
                |FROM
                |   InformationRegister.Requests AS Requests
                |WHERE
                |   Requests.Warehouse = &Warehouse
                |   AND Requests.Period BETWEEN &BeginDate AND &EndDate";
   Query.SetParameter("Warehouse", Warehouse);
   Query.SetParameter("BeginDate", BegOfDay(BeginDate));
   Query.SetParameter("EndDate", EndOfDay(EndDate));

   Selection = Query.Execute().Select();
   While Selection.Next() Do
      RecordSet = InformationRegisters.Requests.CreateRecordSet();
      RecordSet.Filter.Warehouse.Set(Warehouse);
      RecordSet.Filter.Period.Set(Selection.Period);
      RecordSet.Write();
   EndDo;

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.