DocumentForm -> DynamicList -> RecordForm



The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Sep 18, 2012
Company:

Hello everyone,
I have DocumentManagedForm and this form has an DynamicList attribute where InformationRegister is given as a base data (acutally CustomQuery but InformationRegister is base table). When I try to add record to this InformationRegister in DocumentForm, RecordForm opens of course. One of attributes of InformationRegister is Document.Ref. I would like to have this attribute filled with value of Document.Ref when I try to add record from DocumentManagedForm and RecordForm is opened. I don't know how to do it. Would you help me?
I tried to find something like FormOwner for RecordForm (I thought that maybe DocumentForm is the FormOwner) but without result. I tried also some other things but it doesn't work. Would you have any idea how to do it?
Thank you in advance for your help.
Kris

 
#2
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

You can use custom handler to open form and add some Parameters (for example DocRef) and use this parameters in OnCreateAtServer event of the record form.
There could be an easier way... But my way should work 100%

 
#3
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Sep 18, 2012
Company:

I have added parameter DocRef to OnOpen handler of DocumentForm, where Zaopatrzenie is a DynamicList of Information Register and in CustomQuery of DynamicList parameter is used to filter records and it works fine.

Code
Procedure OnOpen(Cancel)
      
    ThisForm.Zaopatrzenie.Parameters.SetParameterValue("DocRef",Object.Ref);   
   
EndProcedure


But later I add the record to Zaopatrzenie and the RecordForm is open and OnCreateAtServer of this form is executed and I don't know how to use this parameter here. The RecordForm is form of InformationRegister and it cannot see the parameter of DocumentForm (or I cannot find it). I don't know how the RecordForm should know where it is open from (i.e. from DocumentForm or from InformationRegisterList). If it is open from DocumentForm then DocRef should fill the attribute of record in RecordForm using parameter. That's my problem. Maybe I don't understand, maybe I do something wrong, so I will be thankful if you explain me. If more details will be necessery please just let me know.

 
#4
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Sep 18, 2012
Company:

Problem solved:

Code
   
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   Zaopatrzenie.Parameters.SetParameterValue("DocRef",Object.Ref);
   FilterItem = Zaopatrzenie.Filter.Items.Add(Type("DataCompositionFilterItem"));
   FilterItem.LeftValue = New DataCompositionField("DocRef");
   FilterItem.RightValue = Object.Ref;
   FilterItem.Use = True;
   FilterItem.ComparisonType = DataCompositionComparisonType.Equal;    
EndProcedure


and in DocRef attribute in InformationRegister I had to check "Fill with data..." in Properties

 
#5
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

I am glad you figured it out.

 
Subscribe