Internet Windows Android

1c 8.3 example of conditional design. Why conditional styling might not work on a managed form

Conditional appearance of managed forms.

Most of those who have worked with ACS and creating reports on ACS know about conditional design not by hearsay. Changing the font of a field, the color of a cell, or the presentation depending on the value in another field is already quite common thing.

But we are less common with the conditional design of managed forms. Although it is no less powerful, functional and necessary mechanism.
What is he like. And everything is the same. According to some condition, we can customize the views or properties of the fields of the tabular form elements and they will change right on the fly.

I'm talking about dynamic list fields and table fields. Here, from the code, we can refer to a separate column and set properties for the entire column at once, but we cannot set the properties of a separate field.

Quote

Important!!! Many people face this and waste their time. Conditional appearance does not work for regular form fields (not tabular).

Where it can be used besides coloring the fields. Well, a classic example is the presentation of views in the tabular section. For accounting, there can be three of them as standard. And usually they line up in one field, one below the other. Since each line may have its own score, the composition of the analysts may differ. And in general, if you display 3 analytics in each line, then it takes up a lot of space. And why do this if we assume that somewhere one subkonto is enough, somewhere two.

Setting by form properties

Let's consider an example of the created tabular section in processing.

Let's create a processing, where we will add tabular part with three details of the Subconto, as well as add the attribute Number of Subconto, which will indicate the number of subconto in the line.

The setting of the conditional appearance of the form is located in the properties of the form on the Appearance tab.

Now our task is to indicate to the program that with the value in the field line Number of Subconto 1, only Subconto1 should be displayed, with the value 2: Subconto1 and Subconto2, with the value 3: Subconto1, Subconto2, Subconto3.

For this, the form for setting up conditional appearance is used.

In the Fields to be formatted column, indicate the fields Subconto1, Subconto2, Subconto3. Since there will be a different design for each field, we will get 3 lines.

We indicate that we will make out the visibility property.

And also set up the condition under which the visibility will be turned off.

Let's see what happened in the enterprise. At the same time, add rows to the tabular section and arrange the values ​​for the number of subcontoes.

As you can see, different lines display a different number of fields.

Setting by code

Beyond customization with properties this setting can be produced using program code.
If you use a configuration built on, it will look like this (this applies to all typical ones):

ElementUO = Conditional.Elements.Add ();
DataCompositionClientServer.Add FormableField (ElementUO.Fields, "TabularSubConto2");

SharedAssignmentClientServer.AddCompositionElement (UO.Selection,
"TabularPartNumberSubconto", DataCompositionComparisonView.Less, 2);

ElementUO.Design.SetValueParameter ("Visibility", False);


In case the BSP is not used, the code will be slightly longer. I will just give you typical procedures from the same BSP.

AddFieldField (StyledFields Collection, FieldName) Function

ElementField = Collection of StyledFields.Elements.Add ();
ElementField.Field = NewDataCompositionField (FieldName);

Returning an ElementField;

EndFunction


Function AddCompositionElement (AddScope,
Value FieldName,
Value ViewComparison,
Value RightValue = Undefined,
Value Representation = Undefined,
Value Usage = Undefined,
value Display Mode = Undefined,
valueCustomSettingId = Undefined) Export

Element =AddScope.Elements.Add (Type ("DataCompositionFeatured Element"));
Element.LeftValue = NewDataCompositionField (FieldName);
Element.CompareType = ComparisonType;

If Display Mode = Undefined Then
Item.DisplayMode = DisplayMode ofDataCompositionSettingsSettings.Not available;
Otherwise
Element.Display Mode = Display Mode;
EndIf;

If RightValue<>Undefined Then
Element.RightValue = RightValue;
EndIf;

If the View<>Undefined Then
Element.View = View;
EndIf;

If Use<>Undefined Then
Element.Use = Usage;
EndIf;

// Important: setting the identifier must be done
// at the end of the element setting, otherwise it will be copied
// v custom settings partially filled.
If the CustomSettings ID<>Undefined Then
Element.UserSettingId = UserSettingIdentifier;
ElseIf Element.Display Mode<>ItemDisplay ModeDataComposition Settings.Not Available Then
Element.CustomSettingsID = FieldName;
EndIf;

Return Item;

In this publication, we will consider an example of coloring lines of expired documents in a document journal (dynamic list) from the current date and the current time.

Our task is to color the line in pink if the Deadline is less than the Current date, taking into account the fact that the current date is constantly changing. That is, the current date should be read dynamically, and not determined at the first opening.

We will learn how in managed form:

Use a wait handler;

Configure programmatically conditional design dynamic list

Let's say we have a “Smart order” document with the “Check Term” attribute and the “Date” type (the composition of the date is “Date and Time”):

And the document journal "Smart Order" with the column "Control Term" corresponding to this requisite:

Our task is to color the line in pink if the Deadline is less than the Current date, taking into account that the current date is constantly changing.

Let's create a managed form:

Now, when we create it on the server, we will call the "RenewalDisplayOfDeliveryOnServer" string coloring procedure. And we will call this procedure at a given frequency.

We have some form of a list, for example, of the elements of the plan of the characteristic type "UserRights" in the "Manufacturing Enterprise Management" version 1.3.

The form, as you can see, is manageable. we need to style the list in such a way that all rows of element groups are highlighted in green. Let's get started!

Example

Managed form elements are styled using conditional form styling:

To solve our problem, let's add a conditional design element with the following settings:


The next time you open the form, the plan group lines of the characteristic types must be highlighted in green. But ... it doesn't!


The point is that the list of elements and groups of the chart of characteristic types is displayed on the form using a form object of the "Dynamic list" type. Dynamic lists use the capabilities of the data composition system, including selections and conditionals. The latter determines the final design of the list, ignoring the conditional design settings of the form itself. Let's add similar conditional appearance settings for the dynamic list.


The only difference is that all visible list fields must be added to the list of styled fields, to which the conditional design should apply.

Output

I've often heard that conditional on managed forms doesn't always work. As a result, it turned out that you just made the settings for the form, and not for the dynamic list.

I hope this article will save someone some time while solving problems with conditional design.