Clearing information registers for the 1s processing period. Creating and deleting information register entries. Processing for deleting information register entries

Quick Jump

Software option for complete cleaning:

When executed, register information entries will be quickly deleted. If the information register is large, this will take some time, but usually a couple of seconds.

Record set is a special “manager” for managing a group of records.

If selection by dimensions is not set and initial reading is not performed using the Read() method, then at the time of calling Write(), the current empty state is saved.

Interactively deleting information register entries

In the managed operating mode of the configuration, multiple selection of register entries is enabled by default, and if the register is independent (not subordinate to the recorder document), it is possible to delete a group of entries.

Using shift, select all entries with the command Ctrl+A and click “Delete” or through the context menu “Delete”

If the number of records is more than 1000, then the system will issue a warning about the duration of operations during selection, but will allow the selection to continue.

For lists of more than 5000 records, using this method is not recommended, since increasing the list of rows in the table field slows down its operation sharply

In regular forms, you can standardly delete one line at a time.

Processing for deleting information register entries

  • In addition to changing and deleting register entries, the ability to use a custom algorithm has been added.
  • Selecting a PC from the list, a dynamic register list is displayed on the form.
  • Generates fields for changing the current record directly on the form. You can change, add, delete entries.
  • For a group of records (selected rows of a dynamic list), you can change fields, including dimensions. IMPORTANT: The recording is in overwrite mode, so if the final record already exists or you have changed the only dimension of a group of records, the consequences can be disastrous. But I hope you understand what you're about to do.
  • When changing fields, the frame is highlighted. You are always aware of what will change. This is especially true for groups of records.
  • It is possible to record in download mode
  • It is possible to set additional recording properties (sometimes very important)
  • Uses privileged mode.
Group processing of information registers based on processing from Gmix
  • Changing (from one to all fields), deleting and copying (with replacement of any number of fields) records of information registers.

In this article we will look at how to properly delete and write information register entries. Moreover, first of all, we will consider deleting records, because It is not so much important to create new records as to preserve existing ones.

And if you handle the information register carelessly, it is very easy to delete all existing entries, as will be shown below. As an example, we will use this information register

Deleting information register entries

As you know, a set of records is used to work with the information register. Let's write two simple lines of code for our register and run them

SetRecord = InformationRegisters. Price. CreateRecordSet() ; SetRecord. Write() ;

Congratulations! We just deleted all the entries in the information register. Although it would seem that nothing criminal can happen when writing an empty set of records. But if you turn to the syntax assistant, you can see that there is no contradiction. If we write a set of records and in the method Write() not specified in parameters Lie(and by default, True is substituted), then the existing set of records is replaced with the one we are recording, in accordance with the established selection. And since we did not set up a selection, all register records are selected for replacement and successfully replaced with an empty set of records. And this is a rake that is sometimes stepped on by developers who are not the first day in 1C. By the way, if we deliberately want to completely clear the register, then this is precisely the method that should be used. I draw attention to this because quite often there is code where, before deleting, a set of records is read, then cleared, and only then written. Although reading and clearing the recordset is completely unnecessary here.

Now imagine that we need to delete not all register entries, but only those with specific measurement values. The algorithm of action in this case is the same, only before recording it is necessary to set the appropriate selection for our empty set of records. In the article about, we looked at the same information register as an example - Price. Let me remind you that we had the following records there:

Let's say we want to delete records where Product - Pencil, A Period - 01/01/2017. Let me remind you that for periodic information registers, selection can be set not only by dimensions, but also by period. In this case, our code will look like this

SetRecord = InformationRegisters. Price. CreateRecordSet() ; SetRecord. Selection. Period. Set("20170101"); SetRecord. Selection. Product. Set(Directories. Products. FindByName("Pencil") ) ; SetRecord. Write() ;

I would also like to draw your attention to the method Install(). In the case when the type of comparison in the selection is Equals This method allows you to set up selection with a minimum amount of code.
After executing this code, the following entries will remain in our register

There may, of course, be more complex cases when deleting records. For example, when you need to delete records for certain values ​​of resources or details.

Here it is no longer possible to use selection, because it can only be set for measurements, recorders and periods. And here you will have to iterate through one or more sets of records, delete individual records and rewrite the set.

Adding entries to the information register

As an example of creating information register entries, we will restore previously deleted entries

SetRecord = InformationRegisters. Price. CreateRecordSet() ; SetRecord. Selection. Period. Set("20170101"); SetRecord. Selection. Product. Set(Directories. Products. FindByName("Pencil") ) ; NewRecord = SetRecord. Add() ; NewRecord. Period = "20170101"; NewRecord. Provider = Directories. Counterparties. FindByName("LLC "Lesprom" "" ) ; NewRecord. Product = Directories. Goods. FindByName("Pencil" ) ; NewRecord. Amount = 10 ; NewRecord = SetRecord. Add() ; NewRecord. Period = "20170101"; NewRecord. Provider = Directories. Counterparties. FindByName("PJSC" "Stationery" "" ) ; NewRecord. Product = Directories. Goods. FindByName("Pencil" ) ; NewRecord. Amount = 27 ; SetRecord. Write(False) ;

In method Write() the parameter responsible for replacing existing records is set to Lie. This means that our recordset will only append to the existing one. The first time the code runs successfully. If we try to execute this code again, we will receive a window with an error message, because We already have records with this set of measurements and it is impossible to add another one of the same kind.


But if we set the substitution mode to Truth, then when recording again, no error will occur, because existing entries will be overwritten.

If you are working with a single record, you can use a record manager instead of a set of records.

Not long ago I needed to clear the information register. This register stored the history of changes to some configuration objects and contained several million entries.

The usual option for programmatically clearing an information register that is not subordinate to the registrar is done by writing an empty set of records, something like this:

RecordSet = Information Registers.OurRegister.CreateRecordSet(); RecordSet.Write();

RecordSet = Information Registers. OurRegister. CreateRecordSet() ;

RecordSet. Write() ;

But in this case, clearing the register in this way would take many hours. Therefore, another method was chosen - a quick way to clear the information register.

Step 1. Make a backup copy of the database. This point, of course, is not mandatory, but the habit of making a backup copy before any potentially dangerous action will definitely save your nerves/time/salary/career.

Step 2. Copy the required register of information.

Step 3. Delete the original information register

Step 4. Rename the copy to the original and apply the changes.

In this simple way, clearing the information register will take several minutes, regardless of the size of this register. The difference is that in the second method the information register table is deleted entirely, which is much faster.

This method can be used to clean almost any configuration element. But, of course, no one guarantees the correctness of accounting after such an operation.

If you find an error or inaccuracy, please select a piece of text and click Ctrl+Enter.

There are several types of registers in 1C:

  • Accumulations that store balances or turnover in numerical form;
  • Calculations that store calculation types and calculations themselves are typically used for payroll calculations;
  • Accounting records with data on accounting calculations in the form of Dt-Kt;
  • Information registers.

We will dwell on the latter in more detail, since they allow us to compile data from the database by measurement sections. For example, “Price Nomenclature” stores data for a specific item and characteristics for a certain type of price.

Fig. 1 “Price nomenclature” register

Characteristics

The register can be either periodic or non-periodic, when there is no need to save the sequence of changes. But if you still need to store it, then it is determined within what period the program will establish control over the uniqueness of records: per second, per day, per month, per quarter and per year.


Fig.2 Frequency and recording mode

If you try to create two records within the same period, the program will generate the error “A record with such key fields exists!” and will not allow you to write to the database.

You can also specify the recording mode. The first is with “Submission to the registrar”, in which records will be recorded by documents and in each of them the registrar document will be indicated. If you choose the second - independent mode, then the data is not recorded by the recorder, but is added, for example, directly from the list or as processing.


Fig.3 Recording modes

The peculiarity of the periodic register is that you can use a slice of the last or first ones, obtaining ready values ​​from the database about the last/first set value for a certain date.

Entry into the 1C information register

Rows in a register with a period and a recorder containing information about resources in terms of dimensions are called records.

To add a record to a register, either a record manager or a record set is used. If the entries in the registry have a common key, then you must use a RecordSet. And to record one single record, if all records in the register are unique, you must use the Record Manager.

An example of a record when using the Information RegisterRecordSet object.

Using the recording manager:

NewRecord = Information Registers.Currency Rates.CreateRecordManager(); NewRecord.Currency = Directories.Currencies.FindByName("USD"); NewRecord.Period = Date(31,12,2016); NewRecord.Course = 100; NewRecord.Multiplicity = 1; NewRecord.Write();

When you use a recordset and the Write method, a record is written to the recordset's information register. In this case, either simply adding lines or replacing existing lines in the register can occur. For independent registers, without setting selections, all entries in the register will be deleted and replaced with added entries.

If you write data into a subordinate register without selecting it, an error will occur.

An example of a record using a set of records in the PriceNomenclature information register subordinate to the registrar:

NewRecordSet = Information Registers.Nomenclature Prices.CreateRecordSet(); NewRecordSet.Selection.Register.Set(Link); NewRecordSet = NewRecordSet.Add(); NewDialRecord.Period = Link.Date; NewSetRecord.Nomenclature = Link.Nomenclature; NewSetRecord.Price = Link.Price; NewRecordSet.Write();

An example of a recording through the recording manager:

Record = Information Registers.Currency Rates.CreateRecordManager(); Record.Period = Date; Entry.Course = Course; Record.Currency = Currency; Write.Write();

Search and read information register

To find an entry in the information register and read it, you need the help of queries. For example, we need to get prices entered by a certain registrar:

SELECT Nomenclature Prices.Nomenclature, Nomenclature Prices.Price FROM Register Information.Nomenclature Prices HOW Nomenclature Prices WHERE Nomenclature Prices.Registrar = &Registrar

Changing and deleting entries

To delete an information register entry, for example all EUR exchange rates, use the following code:

Selection Structure = new Structure("Currency", Directories.Currencies.FindByName("EUR")); Selection = Information Registers.Currency Rates.Select(,Selection Structure); While Select.Next() LoopRecordManager = Select.GetRecordManager(); Select.GetRecordManager().Delete(); EndCycle;

To quickly and completely clear the register, you can use the following code:

NewRecord = InformationRegisters.TestRegister.CreateRecordSet(); NewRecord.Write();

To adjust and change the register, as well as quickly fill the register with data, you can write a universal processing.