Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > How to Replace the Input on Basis and Open Other Object Form?

Forum

Search UsersRules
How to Replace the Input on Basis and Open Other Object Form?
#1
Active user
Points:: 32
Joined:: Sep 16, 2011

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?

Profile
#2
Guest
Points::
Joined::

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.