1s 8.3 open the processing form managed application. External processing is stored on disk separately from the infobase
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 will 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 the “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 exportable 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 section Affiliation in the props StorageExternalProcessing.
To open external processing you need:
- Get it from storage.
- Save the processed file to disk.
- Open a form or get a processing object.
- 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) ;