1c open external processing. How to programmatically open external processing? Opening external processing as an object

Home For beginner developers Learning to program

How to programmatically open external processing?

In version 8.2, the application does not work directly with local files located on the computer. The files must be on the server.

Therefore, to open external processing you need to perform the following sequence of actions:

  • transfer the external processing file to the server,
  • connect external processing,
  • open the external processing form.
&On the Client Procedure Command Processing (Command Parameter, Command Execution Parameters) // Place the processing in temporary storage Storage Address = ""; Result = PlaceFile(StorageAddress, "C:\ExternalProcessing.epf", False); ProcessingName = ConnectExternalProcessing(StorageAddress); // Open the form of the connected external processing OpenForm("ExternalProcessing."+ProcessingName +".Form"); EndProcedure &OnServer Function ConnectExternalProcessing(StorageAddress) Return ExternalProcessing.Connect(StorageAddress); EndFunction

To transfer a file to the server, it must be placed in temporary storage. To do this, first on the client, in the handler of the command for opening external processing, with the function PutFile() we are placing a file from the local file system into temporary storage.

The fourth parameter of this function specifies the sign of the interactive mode of selecting an external processing file. If this parameter True, then a file selection dialog appears, in which you can select a file to place in the storage. In our example, this parameter is Lie, and the path to the file, the data from which will be placed in temporary storage, is explicitly specified in the second parameter of the function.

When calling a function PutFile() its first parameter, Storage Address, we specify an empty string. After the function is executed, the path to the external processing file in temporary storage will be placed in this variable. We use this path to connect external processing.

Connection of external processing is performed on the server using the method To plug() external processing manager. As a parameter, it is passed the path to the external processing file in temporary storage - Storage Address. This method returns the name of the connected external processing, - ProcessingName, - which we use to open the form for this processing.

To open an external processing form, use the function OpenForm(), to which the name of the form is passed as the following line: "ExternalProcessing."+ProcessingName +".Form". In the above embodiment, the main processing form opens. You can also open a non-main processing form - this is discussed in the question How to get a non-main processing form? .

When working with external processing, you need to take into account that by default they are launched in the safe mode of program code execution. This means that some features of the built-in language will not be available to them. If you are sure that external processing does not contain malicious code, it can be activated in the normal mode of program code execution. For this, the third parameter of the method is used To plug() external processing manager.

More information about the safe code execution mode can be found in the documentation.

It happens that to work you need to use external processing or a report, but this is not always possible right away. Sometimes, when you try to open external processing or a report using the menu item “File” and then “Open,” an error message appears indicating that access rights are violated.

But first, let’s look at how external reports and processing generally open in “1C: Accounting 8.3” version 3.0. They are usually an archive downloaded from the Internet or obtained in some other way. Once it has been saved, for example to the desktop, by double-clicking we can see its contents.

Actions for the normal interface:

  1. Right-click on the desired file and select the “Copy” context menu item.
  2. We return to the desktop, right-click on the free space and select “Paste” (or simply drag the file from the archive to the desktop).
  3. You can also extract the file from the archive directly to the desired location on the disk (in our example, this is the desktop).
  4. Now select the file with processing on the desktop and click “Open”.
  5. The processing will be open in the program and you can use it.

Actions for a managed interface (for example, Taxi)

  1. Open directly from the file.
  2. In the menu, select “File”, then “Open”.
  3. In the window that opens, go to the desktop, select the processing file and click “Open”.

For greater convenience, you can create a special folder for treatments and store them all in it.

If you can’t open processing or a report, you can use one of two options.

First way

You can register processing in a directory called “Additional reports and processing”. So, we register the processing in the database.

  1. We go to the administration section, select from the list the item of printed forms, reports and processing.
  2. In the window that appears, check the box “Additional reports and processing” and open the link with the same name.
  3. In the new window, click on “Create”.
  4. Read the security warning and click “Continue”.
  5. In the next window, select the location of the file with processing and click “Open”.

Important!

If at this stage an error appears with the text: “It is impossible to connect additional processing from the file...”, you will have to use the second method described below.

  1. If no error occurs, find the “Placement” item in “Commands”.
  2. In the “Command Interface Sections” window, check the Operations section.
  3. In the table we find “Quick access” and open it.
  4. Select all users and click OK.
  5. Click the “Save and Close” button.

Processing has been successfully registered. To open it, you will need to go to the operations section, select the additional processing item, select the one you need and click on “Run”.

Second way

If the processing does not support the registration described in the first option, you can do it differently, namely: again enable the ability to open processing in the database using the “File” menu with the right mouse button “Open”.

  1. Go to the database configurator.
  2. Select “Administration” from the menu, then “Users”.
  3. Double click on the desired user.
  4. Go to the tab called “Other”.
  5. Check the box for “Interactive opening of external reports and processing”.
  6. Click "OK".
  7. We close the configurator, and also, if it was open, the database.
  8. We go into the database again and open the report we need in the “File” menu using the “Open” command.

In this article, we will consider step-by-step instructions for creating external processing in 1C 8.3 in managed application mode; accordingly, we will use managed forms. And most importantly, we will learn how to connect it to the mechanism of “external processing” of 1C configurations built on a library of standard subsystems version 2.0 and newer.

The task will be the following: to create the simplest external processing that will perform a group action on the “Item” directory, namely, set the selected VAT rate percentage for the specified group of items.

To do this, we will immediately make the necessary settings in the program (we are considering the 1C 8.3 configuration: “Enterprise Accounting 3.0” on managed forms).

Checking this box gives us the opportunity to use external processing.

Creating a new external processing in 1C 8.3 using an example

Now let's go to the configurator. In the "File" menu, select "New...". A window for selecting the type of file to be created will open. Select “External processing”:

A new external processing window will open. Let's give her a name right away. It will be offered when saving the processing to disk:

Let's add a new controlled processing form. We indicate that this is a form of processing and it is the main one:

We will have two details on the form:

  • Nomenclature group – link to the “Nomenclature” directory;
  • SelectVATRate – link to the transfer of the VAT Rate.

We create the details in the “Properties” column in the upper right window. Drag them with the mouse into the upper left window. The new details should immediately appear on the form below.

The order of details can be changed using the “Up” – “Down” arrows:

Get 267 video lessons on 1C for free:

All that remains is to add the “Install” button. In managed forms, you can't just add a button to the form. Even if you add it to the structure of form elements, it will not be visible on the form itself. The button must be associated with the command that it will execute. Go to the “Commands” tab and add the “Set VAT Rate” command. In the command properties, create an action. Select the command handler “On the client”. A command can also be added to the form by simply dragging it into the section with form elements.

A procedure of the same name will be created in the form module. In it we call the procedure on the server:

&OnClient

Procedure Set VAT Rate (Command)

SetVATRateOnServer();

End of Procedure

In the procedure on the server, we will write a small request and actions related to setting the VAT rate:

&On server

Procedure SetVATRateOnServer()

Request = New Request;
Request.Text =
"CHOOSE
| Nomenclature.Link
|FROM
| Directory.Nomenclature AS Nomenclature
|WHERE
| Nomenclature.Link IN HIERARCHY (&Nomenclature Group)
| AND NOT Nomenclature.MarkDeletion
| AND NOT Nomenclature. This is a Group”;

Request.SetParameter("Item Group", Item Group);
ResRequest = Request.Execute();
SelectRecordDet = ResRequest.Select();

While SelectRecordDet.Next() Loop

Attempt
SprNomObject.Write();
Exception
Report("Error writing object """ + SprNomObject + """!
|» + DescriptionError());
EndAttempt;

EndCycle;

End of Procedure

We return to the “Form” tab, add a button to the form and associate it with the command:

As such, our processing is ready for use. To call it, in “1C Enterprise” mode you need to go to the “File” – “Open” menu and select the created file.

However, working in this mode is convenient for debugging processing, but is not entirely suitable for the user. Users are accustomed to having everything “at their fingertips,” that is, in the database itself.

This is what the “Additional reports and processing” section is for.

But in order to add our processing there, we must first give it a description and tell the program its properties.

Description of the function “Information about External Processing”

I will give an example of the contents of this function. It must be export and, accordingly, located in the processing module:

Function InformationOnExternalProcessing() Export

DataForReg = New Structure();
DataForReg.Insert("Name", "VAT rate setting");
DataForReg.Insert("SafeMode", True);
DataForReg.Insert("Version", "ver.: 1.001");
DataForReg.Insert("Information", "Processing for setting the VAT rate in the Nomenclature directory");
DataForReg.Insert("View", "AdditionalProcessing");

CommandTable = NewValueTable;
TabZnCommands.Columns.Add("Identifier");
TabZnCommands.Columns.Add("Usage");
TabZnCommands.Columns.Add("View");

NewRow = TabZnCommands.Add();
NewString.Identifier = "OpenProcessing";
NewRow.Use = "OpenForm";
NewRow.View = "Open processing";
DataForReg.Insert("Commands", TabZnCommands);

Return DataForReg;

EndFunction

To better understand which fields of the registration data structure need to be used, let’s look at the details of the “Additional reports and processing” directory:

As you can see, everything is quite simple. Only one attribute does not match: “Launch Option” – “Use”. If we look at the code of one of the common modules, we will see how a bunch of these fields arise:

To determine which fields of a structure are required, you can first not describe it, simply create an empty one, and then use the debugger. If you trace modules when registering processing, it becomes immediately clear which fields are required and which are not.

Connecting external processing in 1C 8.3

To work with external processing (and an external printing form is also an external processing), there is an object ExternalProcessing.

Let's consider two possible cases:

External processing is stored on disk separately from the infobase

To programmatically open external processing in 1C, you need to know the address of its file. Knowing it, you can either open a processing form or get a processing object to carry out further actions with it (for example, to call export functions from an object module).

Opening an external processing form

To programmatically open an external processing form in 1C, use the function GetForm() object ExternalProcessing. The function has several parameters. Consider a simple opening of the main processing form:


Form = ExternalProcesses. GetForm(FileAddress) ;
Form. Open();

To open a minor external processing form, you must specify its name.

//The FileAddress variable contains the full path to the external processing file
Form = ExternalProcesses. GetForm(FileAddress, "MinorForm") ;
Form. Open();

Opening external processing as an object

In order to receive external processing as an object, a function is used Create() object ExternalProcessing.

//The FileAddress variable contains the full path to the external processing file
ProcessingObject = ExternalProcessing. Create(FileAddress) ;

By default, all processing is opened in safe mode. To disable it, use the following options:

//The FileAddress variable contains the full path to the external processing file

External processing or printing form saved in infobase

In many configurations, it is possible to save external printed forms and processing directly in the infobase. The reference book is used for this. ExternalProcessing. The external processing itself is stored as binary data or in attributes StorageExternalProcessing, or in the tabular part Affiliation in the props StorageExternalProcessing.

To open external processing you need:

  1. Get it from storage.
  2. Save the processed file to disk.
  3. Open a form or get a processing object.
  4. If we are dealing with an external printed form, then we can fill in the standard details Object Reference and call the export function Seal.

//The RefLink variable contains a link to the ExternalProcessings directory element
DvData = RefLink. External Processing Storage. Get() ;
FileAddress= GetTemporaryFileName() ;
DvData. Write(FileAddress) ;
ProcessingObject = ExternalProcessing. Create(FileAddress, False) ;