How to Replace the Input on Basis and Open Other Object Form?

The 1C:Enterprise developers forum

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

I would like to prevent a manager to create duplicated Invoices for Customer Orders. To do that I want the new Invoice not to be created when Create Based On operation is performed for the Customer Order which to the other Invoice is already referenced. In that case I want the previously created Invoice to be opened.
Please give and an advice how could I do that?

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

Joined:
Company:

You can use OnCreateAtServer(Cancel, StandardProcessing) procedure for that, here is an example:

Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   
   If Not ValueIsFilled(Object.Ref) Then
      Query = New Query("SELECT
                        |   MyDocument.Ref
                        |FROM
                        |   Document.MyDocument AS MyDocument
                        |WHERE
                        |   MyDocument.UnderlyingDocument = &UnderlyingDocument");
      Query.SetParameter("UnderlyingDocument", Object.UnderlyingDocument);
      
      Result = Query.Execute();
      
      If Not Result.IsEmpty() Then
         ValueToFormAttribute(Result.Unload()[0].Ref.GetObject(), "Object");
         Return;
      EndIf;
   EndIf;

EndProcedure

 
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.