I am completely unfamiliar with 1C, so I can be wrong in terms. Task: Get phone data from the directory using the request. There is a reference book Counterparties, he has details, even the Name, Last Name .., but there is no telephone. But if you go to the form tab, that is, Form1. And it already has a phone text box. How do I pull it out with a query? If I write Select * FROM Directory. Contractors. Forms. Form 1 then an error will occur.
1 answer
You did not specify either the version of the 1C platform (7.7, 8.x), or the configuration (typical or custom-written), so I can only make a guess. Most likely, information about the phone (as well as about other contact information of the counterparty) is contained in the Contact Information (this is a separate table associated with the Counterparty directory), therefore, in order to get information from there, in the query you need to connect the tables with a left connection, approximately So:
"ВЫБРАТЬ | Контрагенты.Ссылка КАК Контрагент, | КонтактнаяИнформация.Представление КАК Телефон |ИЗ | Справочник.Контрагенты КАК Контрагенты | ЛЕВОЕ СОЕДИНЕНИЕ РегистрСведений.КонтактнаяИнформация КАК КонтактнаяИнформация | ПО КонтактнаяИнформация.Объект = Контрагенты.Ссылка |ГДЕ | Контрагенты.Ссылка = &Ссылка" This is a simplified example. In real typical configurations, the Contact Information register, in addition to the object reference, also contains dimensions such as Type and Type (in order to store all types of contact information — addresses, telephones, e-mail, etc.) in one table. ), so the request will be more complicated. I will give an example of getting a counterparty phone for UPP 1.3 configuration:
Запрос = Новый Запрос("ВЫБРАТЬ | Контрагенты.Ссылка КАК Контрагент, | КонтактнаяИнформация.Представление КАК Телефон |ИЗ | Справочник.Контрагенты КАК Контрагенты | ЛЕВОЕ СОЕДИНЕНИЕ РегистрСведений.КонтактнаяИнформация КАК КонтактнаяИнформация | ПО (КонтактнаяИнформация.Объект = Контрагенты.Ссылка) | И (КонтактнаяИнформация.Тип = &ТипКонтактнойИнформации) | И (КонтактнаяИнформация.Вид = &ВидКонтактнойИнформации) |ГДЕ | Контрагенты.Ссылка = &Ссылка"); Запрос.УстановитьПараметр("ТипКонтактнойИнформации", Перечисления.ТипыКонтактнойИнформации.Телефон); Запрос.УстановитьПараметр("ВидКонтактнойИнформации", Справочники.ВидыКонтактнойИнформации.ТелефонКонтрагента); РезультатЗапроса = Запрос.Выполнить().Выбрать(); Если РезультатЗапроса.Следующий() Тогда Телефон = РезультатЗапроса.Телефон; КонецЕсли; - Thank you very much. What you need - sergileon