The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 2
Joined: Jul 3, 2013
Company: TRIAX

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! :(

 
#2
People who like this: 0 Yes / 0 No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

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

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

Joined:
Company:

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;

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