Opening a programmatically created new document form

The 1C:Enterprise developers forum

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

Hi!
I have a command which creates a document object and fills some attributes. I need it to open this document's form after that. How can I do this?

 
#2
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 17, 2012
Company: Zoi TechCon GmbH

Hi!

Code
 Form = CreatedDoc.GetForm();
 Form.Оpen();

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

It does not work:

Code
&AtClient
Procedure CreateDocument(Command)
   CreateDocumentServer();
EndProcedure

&AtServer
Procedure CreateDocumentServer()
   NewDocument = Documents.Payment.CreateDocument();
   NewDocument.Bank = Object.Ref;
   Form = NewDocument.GetForm("DocumentForm");
   Form.Open();
EndProcedure


I receive:
{Catalog.Banks.Form.ItemForm.Form(35)}: Error calling context method (GetForm)
Form = NewDocument.GetForm("DocumentForm");
because:
Interactive operation not enabled

 
#4
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 2, 2012
Company: BizzSimple.com

(3) you may try 2 ways:
1) save document into database and open at client value from reference,

Code
&AtClient
Procedure CreateDocument(Command)
    Ref = CreateDocumentServer();
    OpenValue(Ref);
EndProcedure

&AtServer
Function CreateDocumentServer()
    NewDocument = Documents.Payment.CreateDocument();
    NewDocument.Bank = Object.Ref;
    NewDocument.Write();
    Return Doc.Ref; 
EndFunction



but if you created document-object without all needable field - you cannot save it, so you must use second way:
2) open new form with parameter and accept it into object form module

As example:
Some button:

Code
&AtClient
Procedure Command1(Command)
   Str = New Structure;
   Str.Insert("Bank", Object.Ref);      
   OpenForm("Document.Document1.ObjectForm", Str);   
EndProcedure


Module in document form:

Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   If not ValueIsFilled(Object.Ref)
      and Parameters.Property("Bank") then      
      Object.Bank = Parameters.Bank;         
   EndIf;       
EndProcedure

 
#5
People who like this:0Yes/0No
Active user
Rating: 6
Joined: Sep 16, 2011
Company:

Thank you, Alexey! The first variant worked for me.

 
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.