Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Choice Form with OR Condition

Forum

Search UsersRules
Choice Form with OR Condition
#1
Active user
Points:: 32
Joined:: Sep 16, 2011

I have a dynamic list on the Choice Form with the Customer field as a reference to Contractors catalog. And I would like to add a filter by this field programmatically to bypass only records with the Customer equal to the one which is passed to this form as a parameter and a System Contractor which must to be available for all documents. I could do this for a single Customer in the following way:

Code
&AtClient
Procedure EvidenceStartChoice(Item, ChoiceData, StandardProcessing)
    StandardProcessing = False;
    FilterValue = New Structure("Customer", Object.Customer);
    ChoiceParameters = New Structure("Filter, CurrentRow", FilterValue, Object.Evidence);
    Evidence = OpenFormModal("Document.GoodsExpence.ChoiceForm", ChoiceParameters);
    If ValueIsFilled(Evidence) Then
        Object.Evidence = Evidence;
    EndIf;
EndProcedure

How to add a System Contractor with OR condition to this filter?

Profile
#2
Guest
Points::
Joined::

Use the following technique in the OnOpen event handler of your Choice Form and pass the customer in the form parameters:
The code for OnCreateAtServer procedure of the ChoiceForm:

Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
    GroupItem = List.Filter.Items.Add(Type("DataCompositionFilterItemGroup"));
    GroupItem.GroupType = DataCompositionFilterItemsGroupType.OrGroup;
    GroupItem.Use = True;
    // The Customer
    Item = GroupItem.Items.Add(Type("DataCompositionFilterItem"));
    Item.ComparisonType = DataCompositionComparisonType.Equal;
    Item.LeftValue = New DataCompositionField("Customer");
    Item.RightValue = Parameters.Customer;
    Item.Use = True;
    // The System Contractor
    Item = GroupItem.Items.Add(Type("DataCompositionFilterItem"));
    Item.ComparisonType = DataCompositionComparisonType.Equal;
    Item.LeftValue = New DataCompositionField("Customer");
    Item.RightValue = GetSystemContractor();
    Item.Use = True;
EndProcedure

The code for StartChoice event handler of the Evidence field:
Code
&AtClient
Procedure EvidenceStartChoice(Item, ChoiceData, StandardProcessing)
    StandardProcessing = False;
    ChoiceParameters = New Structure("Customer, CurrentRow", Object.Customer, Object.Evidence);
    Evidence = OpenFormModal("Document.GoodsExpence.ChoiceForm", ChoiceParameters);
    If ValueIsFilled(Evidence) Then
        Object.Evidence = Evidence;
    EndIf;
EndProcedure

Remember to add a Customer parameter to the ChoiceForm.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.