Choice Form with OR Condition

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Sep 16, 2011
Company: individual

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?

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.