Menu
Is free
registration
home  /  Problems/ Form data to value 1s 8.3. Managed form credentials (1Cv8)

Form data in value 1s 8.3. Managed form credentials (1Cv8)

Listed below are the main 1C objects that are used when working with managed forms. Brief code examples are given that demonstrate the traditional use of these objects when writing 1C configurations.

This Form

Used in a form module, in procedures& OnClient and & OnServer.

Allows you to access both form elements and attributes.

A form element is accessed through an object Elements and looks like this:

ThisForm.Elements.VersionNumber.Header = "v." + ProgramVersion;

The reference to the requisite existing on the form is as follows:

ThisForm.Announcement text = "Hello, comrades!";

Simplified access to form elements and props

In principle, in the form module, you can omit the keyword This Form ... You can refer to form elements and attributes in a simplified way:

// Form element

Elements.VersionNumber.Header = "v." + ProgramVersion;

// Form props

Announcement Text = "Hello, comrades!";

Features of obtaining form details (important!)

If the form props are of simple type - String, Number, Date ... then you can get (set) the value of an attribute simply by name:

Text = Product Name; // Product name is a form attribute

However, in this way it is impossible to get the details of the "complex" type -Table of Values, Value Tree ... If you try to get an attribute with this type by name, an object of the type will be returnedDataFormsCollection.

To get the value of an attribute with a "complex" type, you need to use the functionPropsFormVValue ():

CurrentTable = FormInValue ("SelectedConstructionObjects");

To set the value of a "complex" variable, you can use the functionValueBForm Attribute (<Значение>, <ИмяРеквизита>) both parameters are required.

Functions PropsFormVValue () and ValueBForm Attribute ()available only on the Server.

An object

Strictly speaking, such keyword within the form, no. It's just that when a form is created, for example, an element form, 1C automatically creates a props with a name on the form An object ... This attribute provides access to the properties of the current object, which is being edited on the form.

or, a more complete record:

This Object

Contains the object itself. It is intended for getting an object in an object module or a form module.

Usage: Read only.

Availability: Server, Fat Client, Outside Connection.

In the days of the fat client, calling an object module procedure from a form module was simple. It was enough to define the module procedure as exported and call it in the form module.


Times change, the 1C platform is optimized and improved, the fat client is forgotten, give everyone a thin or web client. Developers are starting to translate regular forms into managed ones, but not everything is so simple, there are some difficulties in connection with the separation of execution program code into two contexts: server and client. Therefore, the above code example will not work in the thin client.

New data types

Also, because of managed forms, new data types have appeared. There is a form:
Remember the types of attributes and see what types in debugging for these attributes:

New Form Data Types
We conclude that to display the data of the object itself, the type is used DataFormsStructure, to display a tree of values ​​- DataShapeTree, for the tabular part - DataFormsCollection etc. That is, in the form module on the client, we work not with the object itself, but with its presentation! Therefore, the methods that are available, for example, for the tabular section in the object module NOT AVAILABLE in the form module.

Fighting new types

The developers of the 1C platform provided two functions:
  1. PropsFormVValue- converts the specified form attribute into an object of the applied type.
  2. Form DataValue- converts the form data into an object of the applied type.
Calling these functions is only available on the server. Let's go back to our task and write the code for the thin client in the form module in the event OnCreateAtServer which will call the function from the object module:
&On server


SproObject1 = Form AttributeValue ("Object");
SprObject1.DisplayMessage (Object.Props1);




End of Procedure

Works with one function and another O_o. Let's write the conversion code DataShapeTree into an object of an applied type:
&On server
Procedure OnCreateAtServer (Failure, StandardProcessing)

ValueTree1 = Form AttributeValue ("Attribute1");
ValueTree2 = FormDataValue (ThisForm.Props1, Type ("ValueTree"));

End of Procedure

ValueTree1 and ValueTree2 have the same type - ValueTree. So what is the difference between these functions ???

Form DataValue - function global context. Converts the type of object supported by the form to the type of the database object: FormDataStructure -> ReferenceObject. Reference1.

PropsFormVValue - the function of the form module, that is, it is called on the server in the context of the form (& OnServer). If you try to call this function outside the context of the form, the platform will generate an exceptional error:
& OnServerWithoutContext
Procedure ConvertType ()

// This code is wrong, the form context is not available, there will be an error!
RefObject2 = FormDataValue (Object, Type ("ReferenceObject. Reference1"));
SprObject2.DisplayMessage (Object.Props1);

End of Procedure

That's all the difference.

Processing shows all the details of the selected object, allows you to edit them, as well as compare two objects of the same type. Supports any configurations, it is automatically installed in standard ones.

Current version: 1.09 for regular forms, 1.12 for managed forms.

Download processing (for 1C 8.2, 1C 8.3 (regular forms), epf file, 47 KB)

Download processing (for 1C 8.2, 1C 8.3 (managed forms), epf file, 22 KB)

The latest version for 1C 8.1: 1.05

Download processing (for 1C 8.1, epf file, 48 KB)

What to do if processing does not open

Processing is very useful, for example, in such cases:

    need to sort out an unfamiliar database

    the configuration release was updated and a new field was added to the document (hidden, but it is not in the form). At the same time, for new documents, it is established when they are created, but the old ones were naturally forgotten. Which for the user is expressed in the fact that two completely identical documents give different transactions 🙁

    it's just that the contents of the field do not fit into the space allocated to it on the form, but you need to view it in full (tabular sections especially suffer from this - developers are very fond of limiting the width of the columns and, in addition, not allowing it to be changed)

    you need to go to the related information (for example, open the one specified in the CCD invoice), but they forgot to make this field available (that is, neither buttons with dots or a magnifying glass nor F4) (and it also happens that instead of an input field, they make a selection field, an inscription or a field generally absent on the form 🙁)

    you need to compare two objects of the same type

Distinctive features are

    the ability to connect to typical configurations as a printable (i.e. in a purely user mode, no configurator is needed)

    the ability to record an object in the "data exchange - download" mode - i.e. "as it is"

Installation (normal interface)

Processing is open, follow the instructions on the screen. (Ie, click the "Installation" button in the upper right corner and confirm the installation in the next window.

Installation ("managed" interface)

Attention: This option the installation works only in typical 1C configurations.

1. Go to the "Administration" section and there - "Additional reports and processing".

2. Press the "Add" button and select the file dannye-objecta-upr.epf

3. In the processing settings window, check that:

    Publication: Used

    Checked boxes: use for list form, use objects for form

4. Confirm the installation by clicking OK

Use of processing

From the form of the document, the element of the directory. either list form

    Normal interface - press the "Print ..."

    "Guided" interface - press the fill button

Select "Object data" in the menu - the processing form will open

To view the requisite (for example, the document contains the “Agreement” attribute, it is unavailable for modification. But you need to open the card of this agreement).

How to get props from a reference value on the client

In the processing form, click on the attribute value.

To change the attribute - check the box next to the value. The value can then be changed.

To save the changes - press the button of the required option to save the entry in the "data exchange - download" mode, regular entry... conducting (only for documents).

If you need to record some of the changed requisites and record some of them, uncheck the boxes next to what should be recorded.

In processing there is "Data of the requisite" - it's like you would open a value by reference (for example, a counterparty card) and call processing in it again.

Comparison of objects can be done:

Selecting 2 objects for processing

2. Calling processing from one object, then (without closing the window) from another. You will be prompted to make a comparison.

3. (Only "managed" interface). Select 2 objects in the list at once (to do this, hold down the Ctrl button) and call processing - the objects will be compared.

Screenshots (normal interface)

Screenshots ("managed" interface)

Examples of using processing to analyze problem situations.

Changes in version 1.12 (17.10.2017)

  • For the variant with managed forms, a bug has been fixed (the attribute in the tabular section was not updated if the object itself had a header attribute with the same name)

Changes in version 1.10 (06.01.2017)

  • For the variant with managed forms, work has been fixed in some typical configurations (Accounting, UNF)

Changes in version 1.09 (07.07.2015)

  • Added display of fields "Parent", "Owner"
  • For the version for the managed interface, work without modal windows is provided.

Changes in version 1.08 (04/03/2014)

    For the version for the normal interface, improved compatibility when working in the "Manufacturing Enterprise Management" (PPM) 1.3 configuration.

Changes in version 1.07 (04/03/2013)

    There is a version of processing for "managed" forms (the function of automatic installation and update is only in the version for normal forms)

    Bug fixed (rights were set in the processing distribution)

Changes in version 1.06 (05/13/2012)

    Displaying the "Object version" field

    Bug fixed (it was not possible to set read-only permissions in processing)

Changes in version 1.05 (04/05/2011)

    Fixed a bug (when working under 8.2, the document record was not available in the posting mode)

Changes in version 1.04 (04/13/2011)

    Fixed a bug (when working under 8.2, double-clicking the mouse did not open the details)

    Now processing can proceed to displaying the reference type attributes.

    That is: let's say that you have opened the view of the details of the document "Sale of goods, services". V this document there is a "Counterparty" variable of the "DirectoryLink.Contractors" type. By clicking on this requisite with the right mouse button, you will receive context menu, in which there are items "Attribute data" and "Attribute data in a new window". By choosing one of them, you can view the details of the corresponding counterparty.

Changes in version 1.03 (15.10.2010)

    Added the ability to set users and their access rights to processing.

Changes in version 1.02 (08/21/2010)

    Supported configurations in which the reference external treatments called "Supplementary Print Forms".

Changes in version 1.01 (01/28/2010)

    Fixed a bug that occurred when Object1 was empty and Object2 was selected (thanks to rasswet for showing it);

    The checkbox "detail" is triggered immediately, you do not need to click on "Show";

    The column "Value type" has been renamed to "Possible value type" and shows the value type defined for this variable in the configurator. For attributes with a composite type, in addition to this, the type of the value of this attribute in the viewed object is shown.

If you connected processing to your configuration, then to update it:

download the processing, open it as an external one, it will tell you what and how to click (the "Install" button, select "Update processing in the database", click the "Execute" button)

Print (Ctrl + P)

There is a set of global methods for converting application objects to form data and vice versa:

  • ValueInForm Data (),
  • FormDataValue (),
  • CopyFormData ().

Methods that work with application objects are available only in server procedures. The method for copying values ​​between form data is available on the server and on the client, since it does not require application objects as parameters.

When converting form data to an application object, consider compatibility.

  • ValueInDataForm() - converts an object of an application type to form data.
  • Form DataValue() - converts the form data into an object of the applied type.
  • CopyDataForm() - copies form data with a compatible structure. Returns True if the copy was made, or False if the structure of the objects is incompatible.

When converting form data to application objects and vice versa, object caching is used, but at the same time, the validity of the version of the object in the cache is checked.

NOTE. When performing standard actions (opening a form, performing standard command Record, etc.) in the form with the main attribute, the transformation is performed automatically.

Here's an example of how to use data transformation in your own algorithms.

&On server
Procedure OnCreateAtServer (Failure, StandardProcessing)
ObjectObject = Goods.FindByName ("Coffee pot"). GetObject (); ValueVDataForm (ObjectObject, Object);
End of Procedure
& OnClient
Procedure Write ()
WriteOnServer ();
End of Procedure
&On server
Procedure WriteOnServer ()
ObjectObject = FormDataInValue (Object, Type ("DirectoryObject.Goods"));
ObjectObject.Write ();
End of Procedure

Also, the ClientApplicationForm object has methods available on the server:

  • ValueBForm Attribute () - converts the object of the applied type into the specified form attribute.
  • PropsFormVValue() - converts the form data attribute into an object of the applied type.

Using these methods is usually more convenient, since they have, for example, information about the type of the form attribute. In addition, the FormAttributeValue () method performs the mapping between the form data and the object, which is used when generating messages.

It should also be remembered that when converting to form data (both using the ValueBFormData () method and using the ValueBFormAttribute () method) of objects of the ValueTable or ValueTree type, you need to take into account the following feature: all columns that exist in the data must exist in the converted object forms.

ATTENTION! Non-data-related attribute columns are not involved in converting values ​​between form data and objects information base and back. Columns not present in the object data are cleared when converted to form data.

When transferring an object to form data by the framework, or when calling methods ValueInDataForm(), ValueInPropsForm(), only the object data is transferred. The internal state of the object is not transferred to the form data. For example, the value of the new reference, which is set to the object by the method SetLinkNew (), will be lost in the process of converting the object to and from form data.

As the first parameter of the methods PropsFormVValue() and FormDataValue (), only form attributes of the following types can be used:

  • FormDataStructure,
  • Form Data Collection,
  • DataFormsStructureCollection,
  • FormDataTree.

Let's give an example of using these methods.

&On server
Procedure RecalculateAtServer ()
// Converts the props Object to an application object. Document = FormInValue ("Object");
// Performs recalculation using the method defined in the document module. Document.Recalculate ();
// Converts the application object back to props. ValueВForm Attribute (Document, "Object");
End of Procedure

Form details

The set of form attributes describes the composition of the data that is displayed, edited or stored in the form. At the same time, the form details by themselves do not provide the ability to display and edit data. Form elements (see the section "Form elements" of this chapter), associated with form attributes, are used for displaying and editing. The set of all the form details will be called form data.

Important! It must be remembered that, unlike regular forms, all data managed form must be described in the form of requisites. It is not allowed to use form module variables as data sources for form elements.

It is possible to assign The main requisite of the form, that is, a props that will define the standard functionality of the form (form extension). It should be remembered that a form can have only one main attribute.

Expanding the form- these are additional properties, methods and parameters of the ManagedForm object form that are specific to the object that is the main element of the form.

In the process of developing a form, you can explicitly set the ability to view and edit specific details of the form, in terms of roles, using the View and Edit properties (for more details, see the section "Role-based form customization" of the "Editors" chapter). In addition, the availability of a particular attribute in the form itself can be configured using functional options (for more details on functional options, see the chapter "Managing the configuration interface").

Form props property Stored data is a sign that an interactive change of the props will lead to an attempt to block the form data for editing, as well as to automatic installation a sign of form modification.

Data types available in managed form

A managed form also differs from a regular form in the types of data it works with. If the usual form works with most of the types that 1C: Enterprise provides (including the type DirectoryObject, DocumentObject, etc.), then the following categories of types can be distinguished in the managed form:

  • types that are directly used in the form are those that exist on the side of the thin and Web client (for example, Number, ReferenceRef.Products, GraphicalSchema, TabularDocument);
  • types that will be converted to special data types - managed form data types. Such types are displayed in the list of form attributes in parentheses, for example (ReferenceObject.Goods);
  • dynamic list (see the section "Dynamic list" of this chapter for more details).

Converting Application Objects to Form Data

Some application types (such as DirectoryObject, etc.) do not exist on the side of thin and Web clients (for more details, see the chapter “Concept managed application"). Therefore, to represent such application types in the form, the platform has introduced special data types designed to work in managed forms. This feature of a managed application necessitates the conversion of application objects to form data (and vice versa).

The following data types are used:

  • FormDataStructure - contains a set of properties of an arbitrary type. Properties can be other structures, collections, or structures with collections. This type is represented, for example, in the form DirectoryObject.
  • A FormData collection is an array-like list of typed values. An item in a collection is accessed by index or identifier. Access by ID may not be available in some cases. This is due to the type of application object represented by this collection. The identifier can be any integer. This type is represented, for example, in the form of a tabular section.
  • FormDataStructureCollection is an object that is represented as a structure and a collection at the same time. It can be treated like any of these entities. This type is represented, for example, in the form of a set of records.
  • FormDataTree - the object is designed to store hierarchical data.

An application object is represented by either one or more form data items. V general view the hierarchy and composition of form data depends on the complexity and interrelationship of the managed form application objects.

For example, a document containing a tabular section will be represented by an object of the FormDataStructure type (the document itself), to which an object of the FormDataCollection type (tabular section of the document) is subordinate.

Important! When designing a configuration, it is important to remember that application objects are only available on the server, while form data objects can be used on both the server and the client.

Passing Data Between the Client-Side and Back-end of a Managed Form

In fact, we can say that form data is a unified representation of the data of various application objects, with which the form works uniformly and which are present both on the server and on the client. That is, the form contains some "projection" of the data of the application objects in the form of its own data types and converts between them, if necessary. However, if a configuration developer implements his own data processing algorithm, then he must perform data conversion (from specialized types to applied types and vice versa) independently.

When editing the form attributes in a specialized editor (for more details, see the "Form attributes" section of the "Editors" chapter), it is possible to influence the transfer of data between the client and the server while the form is running. To do this, use the column of the attribute editor. Always use... The effect of this property differs for three types of attributes:

  • For an attribute subordinate to a dynamic list (dynamic list column):
    • property on - the attribute is always read from the database and included in the form data;
    • property off - the props are read from the database and are included in the form data only when there is one visible in this moment form element associated with a props or its subordinate props.
  • For props subordinate to the movement collection:
    • property on - document movements are read from the database and will be present in the form data;
    • the property is disabled - document movements will not be read from the database and will not be included in the form data (if there is no form element referring to document movements).
  • Other details of the form:
    • property enabled - the attribute will be present in the form data, regardless of whether or not there is at least one form element that is associated with the attribute or its subordinate attribute;
    • property off - the props will be present in the form data only if there is a form element associated with the props or its subordinate props. Unlike the attributes of a dynamic list, the visibility of the element associated with the attribute does not matter here.

Note. It should be remembered that the property set on the parent attribute affects all subordinate attributes. For example, if the Use property is always cleared for the tabular section of the document, then the system considers that this property is also cleared for all subordinate attributes (despite the actual state of the property).

Methods for Converting Application Object Data to Form Data

There is a set of global methods for converting application objects to form data and vice versa:

  • ValueInForm Data (),
  • FormDataValue (),
  • CopyFormData ().

Important! Methods that work with application objects are available only in server procedures. The method for copying values ​​between form data is available on the server and on the client, since it does not require application objects as parameters.

When converting form data to an application object, consider compatibility.

  • FormDataValue () - converts an object of the applied type into form data;
  • FormDataValue () - converts form data into an object of an applied type;
  • CopyFormData () - copies form data with a compatible structure. Returns True if the copy was made, or False if the structure of the objects is incompatible.

Note. When performing standard actions (opening a form, executing the standard Write command, etc.) of a form with the main attributes, the transformation is performed automatically.

Here's an example of how to use data transformation in your own algorithms.

& AtServer Procedure OnCreateAtServer (Failure, StandardProcessing)

ObjectObject = Reference books.Goods.FindByDescription ("Coffee pot"). GetObject (); ValueVDataForm (ObjectObject, Object);

End of Procedure

& OnClient Procedure Write ()

WriteOnServer ();

End of Procedure

& AtServer Procedure WriteAtServer ()

ObjectObject = FormDataValue (Object, Type ("DirectoryObject.Goods")); ObjectObject.Write ();

End of Procedure

Also, the ManagedForm object has methods available on the server:

  • ValueBFormAttribute () - converts an object of the applied type into the specified form attribute.
  • Form AttributeValue () - converts the form data attribute into an object of the applied type.

Using these methods is usually more convenient, since they have, for example, information about the type of form attribute. In addition, the FormAttributeValue () method performs the mapping between the form data and the object, which is used when generating messages. You can read more about this in the chapter "Navigation service options".

Let's give an example of using these methods.

& AtServer Procedure RecalculateAtServer ()

// Converts the props Object to an application object. Document = AttributeFormVValue ("Object"); // Performs recalculation using the method defined in the document module. Document.Recalculate (); // Converts the application object back to props. ValueVRequisitForm (Document, "Object");

End of Procedure

Programming interface

FormDataTree (FormDataTree)

  • FindById
  • GetItems

Description:

Designed for modeling a tree in managed form data.

This object can be serialized to / from XDTO. XDTO type corresponding this object defined in the namespace. XDTO type name:

GetItems

Syntax:

GetElements ()

Returned value:

Type: FormDataTreeElement Collection.

Description:

Gets the collection of items in the top-level tree.

Availability: client, server, thin client, web client.

FindById

Syntax:

FindById (<Идентификатор>)

Options:

<Идентификатор>(mandatory)

Type: Number. The identifier of the tree element.

Returned value:

Type: FormDataTreeElement.

Description:

Gets a collection item by ID.

Availability: client, server, thin client, web client.

FormDataTreeItem (FormDataTreeItem)

Properties:

<Имя свойства> (<Имя свойства>)

  • GetId
  • GetParent
  • GetItems
  • Property

Description:

Form data tree element.

FormDataTreeItemCollection (FormDataTreeItemCollection)

Collection Elements: FormDataTreeElement

For an object, the collection can be traversed using the operator For each ... From ... Loop. The traversal selects the elements of the collection. It is possible to refer to a collection element using the [...] operator. The index of the element is passed as an argument.

  • Insert
  • Add
  • Index (IndexOf)
  • Count
  • Clear
  • Get (Get)
  • Move
  • Delete

Description:

Collection of tree elements.

Availability: client, server, thin client, web client.

See also:

  • FormDataTreeElement, GetElements method
  • FormDataTree, GetElements method

Features of working with a tree of values

Updating the tree

There is a problem fall platforms when updating the tree.

If a node has been expanded in the tree and a subordinate node has been selected, then when the tree is updated with the function ValueInDataForm the platform falls.

Solution: Before upgrading, you need to clear the tree.

For example:

& AtServer Procedure ClearTree (elements) For each element of the elements Loop ClearTree (element.GetElements ()); End of Cycle; elements.Clear (); End of Procedure

& AtServer Procedure Fill ConceptTree () dzConceptions = cpProperties.Construct ConceptTree (OnDate, Meta.CurrentIB ()); ClearTree (ConceptTree.GetElements ()); ValueVDataForms (Concept, Concept Tree); End of Procedure

& OnClient Procedure OnDateOnChange (Element) Fill ConceptTree (); End of Procedure