A
A
Anton October2016-11-11 19:21:57
1C
Anton October, 2016-11-11 19:21:57

1C how to change all values ​​of one column in "Nomenclature" table?

1C-Enterprise 8.3. I tried to change the values ​​of the "VAT rate" column in the "Nomenclature" table to "Without VAT", in the absence of groupings and working with the entire column, I decided to write a script, I managed to get the column value, and the number of records + the value that needs to be recorded, but I ran into the following: the Write() function; swears at the lack of a method or something like that.
Here is the listing:
Procedure SetOnServer()
Request = New Request;
Query.Text = "SELECT
| Nomenclature.VAT Rate AS VAT Rate1,
| Nomenclature.VAT Rate.Reference,
| Nomenclature.VAT Rate.Order
|FROM
| Reference.Nomenclature AS Nomenclature
|TO CHANGE";
Selection=Request.Execute().Upload();
//CurrentRecord = Directory.Nomenclature.CreateRecordManager();
For each Row from Selection Loop
Document = Row;
Document.VAT Rate1 = Transfers.VAT Rates.Without VAT;
Notify(Document. VAT Rate1);
Write();
EndCycle;
EndProcedures
and screenshots:
5ac009686c8e4600b8f1d4be002792e4.jpg3dfc3065519a491095e454f24e924dd2.jpg
How to update/save/record this unfortunate "Without VAT" in all fields of the column ?
Before that, I had never worked with 1C and I could not find adequate documentation

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kinash, 2016-11-11
@Lyrium

Fast decision. Start group processing of directories and documents (processing that is available in all standard configurations in both the normal and managed interface options), select the type reference nomenclature, apply a selection if necessary, and change the attribute value for all elements.
The path of the programmer. It is necessary to select by request not the properties of the VAT rate from the stock list directory, but links to the elements of the directory (with the selection that this is not a group). Then, by selecting from the request, you get the object by reference, replace the VAT rate and write it back to the database. Looks like this:

Запрос = Новый Запрос("Выбрать Ссылка Из Справочник.Номенклатура Где не ЭтоГруппа");
Выборка = Запрос.Выполнить().Выбрать();
Пока Выборка.Следующий() Цикл
    Товар = Выборка.Ссылка.ПолучитьОбъект();
    Товар.СтавкаНДС = Перечисления.СтавкиНДС.БезНДС; 
    Товар.Записать();
КонецЦикла;

What did you write?
You select the properties of the item (most likely they are the same for everyone = 18%) and then work with an array of identical information. Since your Sample variable contains the Value Table, you can easily override the values ​​of the VAT Rate1 field (a pointless exercise, given that this table will be deleted from memory after the procedure is completed).
Next, you call the Write() context method - which is defined inside the object module and element form module for data objects. In the case of working inside the form of an element of the nomenclature reference book, you would be able to write the current element, but you are most likely working in processing and this method is not available by default in its context - therefore you get an error.

E
Eugene, 2016-11-12
@evgshk

I will add Dmitry that you have had a substitution of concepts. The Nomenclature Directory is one entity, and one of the attributes of this entity "VAT Rate" is, in fact, a link to another entity.
Imagine that you have two tables:
1. Person[Id, Name, Gender] - here the "Gender" field is the Foreign Key to gender table #2
2. Gender[id, Name] The
task is to overwrite the person's gender. You simply go through the elements of the "Gender" table without regard to the elements of the "Person" table you need.
Ah and further Dmitry already told.
Those. you need to start from the fact that you need to overwrite the element of the "Directory. Nomenclature" entity, respectively, and you need to select a link to it and work with it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question