Prevent copying objects by the user

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Jul 31, 2014
Company:

Hello,

what's the correct way to prevent copying objects by the user.

I am currently throwing an exception inside the OnCopy procedure of the
object module.

Thx for your help!

 
#2
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Nov 3, 2011
Company: 1C Company

Oliver,

the platform design implies that copying is just creating a new object (plus filling it with some data). Therefore, providing a special tool that prevents copying just does not seem right.

Throwing an exception inside the OnCopy procedure looks like the best solution to me.

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

Hi, Oliver.

If you don't want to show message box with error there is another solution.
You can hide button "copy".
Open form in Designer, open form's properties, click "open" in the row "command set" and uncheck "Copy". You must do it for all forms.

Unfortunately, in the list form key F9 still works.
We can prevent it with this code.

Code
&AtClient
Procedure ListBeforeAddRow(Item, Cancel, Clone, Parent, Folder, Parameter)
   If Clone Then
      Cancel = True;
   EndIf;
EndProcedure


Or this version in the object form
Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   If ValueIsFilled(Parameters.CopyingValue) Then
      Cancel = True;
      Return;
   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.