E
E
Elena2021-11-13 18:52:41
1C-Enterprise
Elena, 2021-11-13 18:52:41

How to access a table field through another object module?

Through the form module, you can access the field through Element.Products.CurrentData.Price, but how can you access it through another object module?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Prokhorovich, 2021-11-13
@Elena0394

"Current data" in another module, if the memory does not change, does not exist. That is, if you need to do something with them, then in the form module you write them to variables / array / structure / something else and call the desired function of another module. Then, again, in the form module, write the result back to the current data (or where you need to write it).

D
Dmitry Kinash, 2021-11-14
@Dementor

Through the form module, you can access the field through Element.Products.CurrentData.Price,

It's not exactly a field reference. To be precise, here - getting the value of a specific cell (with the name "Price") from the line of the table field selected on the form (with the name "Products").
In more detail:
"Elements" is a collection of all elements on the form
"Products" - a form element of the "table field" type, which is associated either with a table of values ​​in the form attributes, or with the tabular part of one of the field attributes (usually this is the main attribute with the name "Object")
"CurrentData" - a property of the table field of the form for accessing data that is displayed on the form - i.e. contains some part of the table row values ​​that the programmer has decided to make available on the form, i.e. there may not be all!
If on the form you need to access all the columns of the desired row of the tabular section (or table of values), then you need to use the CurrentRow property, which contains the row identifier, and then get the desired row from the form attribute using the FindByID() method
and how to address through other module of object?

If you pass a form context to any other module (you specified the form as a function parameter), then nothing changes. You can get data according to the above scheme, only you need to access it through the context. Those. will be something like this: PassedForm.Items.Products.CurrentData.Price
If the call to the external module is not initiated from the form and the context is not available, then such a thing as "the line selected on the form by the user" does not make sense. You just have a tabular part, which has a lot of rows that can be bypassed by an iterator (in the For each ... From ... Loop construct), a selection (the result of FindRows (Selection)) or by a specified index.
For example, accessing the value of the first line will look like: Object.Products[0].Price , and if you work in an object module, then Products[0].Price is enough

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question