D
D
Danil2018-12-12 18:59:21
1C-Enterprise
Danil, 2018-12-12 18:59:21

How in the form module to access the element located inside the object?

Hello, I have two directories: InformationAboutStudents and InformationAboutParents . The Student Information directory contains information about each student, including the address where he lives. The Parents Information directory contains data on the full name of the parents , their telephone number , address and the full name of their child .
And the task is this: so that in the form of creating a parent when choosing a child for him and clicking on the "Copy address" button, the child's residential address data, which is already filled in for him, would be copied into the "Address" field for the parent, because, as a rule, parents and their children live at the same address.
To implement the task, I created a form
5c112ade24c2f875951399.png
And wrote the following code:

&НаКлиенте
Процедура КопироватьАдрес(Команда)
  Объект.Адрес = Объект.Ребенок.Адрес;
КонецПроцедуры

However, when the button is clicked, this code gives an error Object field not found (Address).
To solve this problem, I tried to rewrite the code and try to get the child's address data using its Unique Identifier:
&НаКлиенте
Процедура КопироватьАдрес(Команда)
  Объект.Адрес = Объект.Ребенок.УникальныйИдентификатор();
КонецПроцедуры

As a result, the unique ID of the selected student is entered into the Parent's Address, but I still don't understand how to use it to access the Address of the selected student and enter it into the Parent's Address. Please help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kinash, 2018-12-12
@OnlyGoRush

The ability to access properties of a reference type through a dot does not work on the client . Those. you will not be able to find out on the client the values ​​of the properties of the object referenced by Object.Child . You can read the properties of the Object itself , because it is a structure, but the Child is already a reference to the reference book. You need to make a server call for this. The easiest way:

&НаКлиенте
Процедура КопироватьАдрес(Команда)
  Объект.Адрес = УзнатьАдрес(Объект.Ребенок);
КонецПроцедуры

&НаСервере
Функция УзнатьАдрес(Ребенок)
  Возврат Ребенок.Адрес;
КонецФункции

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question