Answer the question
In order to leave comments, you need to log in
How to pass the document name through a parameter in 1C?
How to pass the name of the requested table as a parameter to the query, i.e. where to get data?
There is a field on the form that displays a list of document types.
I want that at a choice of any type of documents, the request addressed to documents of this type.
Запрос.Текст = "ВЫБРАТЬ Документ.Организация
| ИЗ &ВидДокумента Как Документ"
Запрос.УстановитьПараметр("ВидДокумента", "Документ." + ЭтаФорма.ВидДокумента);
мдТек = Метаданные["Документы"];
Для каждого ЭлементКоллекции из мдТек Цикл
Элементы.ВидДокумента.СписокВыбора.Добавить(ЭлементКоллекции.Имя, ЭлементКоллекции.Синоним);
КонецЦикла;
Answer the question
In order to leave comments, you need to log in
Looked at your exchange of comments with Konstantin. You have no understanding of how requests work. I'll try in a nutshell.
The query text is an instruction to the database management subsystem for selecting and transforming data. There is a query language syntax, according to which the data source must be described in the WHERE section, following certain rules: if the source is in the system data, then it is described as [ObjectClass].[ObjectName] (in this case, only tabular data can be used as a source, even if they contain only one line - i.e. constants can be used, but enumerations can no longer be used); if the data source is located in the code from which the request is executed, then they write &VariableName and the data source is transferred to the variable of the same name.
So, if the input to the Request object or based on it (it can be a "report builder" or "composition system") is given some text of the request, where in the WHERE section instead of Document.Act and Document.Invoice there will be &DocumentType , then it will go to the passed parameter collection, will look there for a parameter named "DocumentType", move its contents to a temporary table, and execute a query against this temporary table, and not against the real tables of the same documents. Thus, if you set some table of values (or a tabular part, or a result from another query) in the DocumentView parameter, then you will succeed. But when passing a string, as in your case, you will get an error, since the string cannot be implicitly converted to a table.
If you have a table name in some variable, then you should pass the value of this variable to the query text as Konstantin advised, or using text replacement:
Query.Text = StrReplace(Query.Text, "&DocumentView",DocumentType) ;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question