The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Just came
Rating: 0
Joined: Feb 6, 2013
Company:

Hi,

I have two catalogs: CatalogAdresses and CatalogClients. CatalogClients is owner of CatalogAdresses. On ItemFormClients there is DynamicList with adresses. Could you tell me how can I display adresses belongs to each client?

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

Joined:
Company:

Hello, James.

Owners have a navigation panel on the left where links to catalogs having this catalog as an owner are listed. This data will be displayed in the list form that you can open using Addresses link.

See the infobase in the attached file as an example.

By the way, for your task it is much better to use Contact information subsystem from 1C:Subsystems Library.

Download 1Cv8.dt (9.97 KB)
 
#3
People who like this: 0 Yes / 0 No
Just came
Rating: 0
Joined: Feb 6, 2013
Company:

I know that. But how should look query (filter or section WHERE ..., I'm not sure) if I want to display addresses in the ItemFormClients in table?

 
#4
People who like this: 0 Yes / 0 No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

You can use this script for setting filter on DynamicList:

Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   FilterElement = DynamicList1.Filter.Elements.Add(Type("DataCompositionFilterItem"));
   FilterElement.LeftValue = New DataCompositionField("Ref");
   FilterElement.RightValue = Object.Ref;
EndProcedure

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

Joined:
Company:

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.

Download 1Cv8.dt (12.92 KB)
 
Subscribe
Users browsing this topic (guests: 2, registered: 0, hidden: 0)