Back to questions
JuniorTheoryCommon
What happens when this code runs?
Товар = Справочники.Товары.НайтиПоКоду("00001");
Товар.Наименование = "Ручка синяя";
Товар.Записать();An error: a reference's attributes are read-only, an object is needed
- Changing an attribute straight through the reference from
НайтиПоКоду: a reference only reads, the object fromПолучитьОбъект()is what changes - Expecting the change to be saved later by itself: nothing reaches the infobase without an object and its
Записать()
- How do you rewrite this code so the new name reaches the infobase?
- Why should you not call
ПолучитьОбъект()just to read one attribute?