Yes, you do not need to perform joins in this case. You can use a dynamic list without of the custom query.
If you want to make Addresses item form to substitute owner automatically when you create an item in this list, you need to set filter by owner for this dynamic list.
But there might be already created filter by owner, for example saved by a user manually. So you should to search for existing filter first.
In addition you should update filter after the catalog item is written due to when a new item is created there is no reference to it and filter will not work correctly.
| Code |
|---|
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
SetAddessesOwnerFilter();
EndProcedure
&AtServer
Procedure AfterWriteAtServer(CurrentObject, WriteParameters)
SetAddessesOwnerFilter();
EndProcedure
&AtServer
Procedure SetAddessesOwnerFilter()
LeftValue = New DataCompositionField("Owner");
RightValue = Object.Ref;
FilterItem = Undefined;
For Each CurFilterItem In Addresses.Filter.Items Do
If CurFilterItem.LeftValue = LeftValue Then
FilterItem = CurFilterItem;
EndIf;
EndDo;
If FilterItem = Undefined Then
FilterItem = Addresses.Filter.Items.Add(Type("DataCompositionFilterItem"));
FilterItem.LeftValue = LeftValue;
EndIf;
FilterItem.RightValue = RightValue;
FilterItem.ComparisonType = DataCompositionComparisonType.Equal;
FilterItem.Use = True;
EndProcedure |
See the example in attached files.