This article will tell you in detail how a beginner with little knowledge of 1C 8 can create printed form. For example, let's take one of the most common 1C 8 configurations - Accounting 2.0. Creating a printed form 1C stages of writing:
- Creating an external printing form file;
- Creation of a printed form layout;
- Writing program code to display printed form data on the screen;
- Creating parameters for auto-registration of a printed form;
- Connecting an external printing form to the base 1C Enterprises.
Creation of a printed form 1C. Statement of the problem
We are required in the configuration Accounting 2.0 create a printed form for a document Receipt of goods and services. In the header of the printed form, display the following data:
- Organization;
- Counterparty;
- Counterparty agreement;
- Date of receipt.
Display the data in the tabular section as a table Goods document. The table should include the following columns:
- Nomenclature;
- Quantity;
- Price;
- Sum;
- And also the price of the item for the current date (by type of price from the document).
External processing file
Let's move on to solving the problem. First, let's open 1C 8 in mode Configurator. It is in this mode that all developments are carried out on the 1C 8 platform. Now we need to create an external processing file. To do this, click on the menu File -> New… or by the icon of a new file.
In the window that opens, select the item External processing.
Next in the field Name You must enter the name of the external processing. In our case, we’ll simply call it “PrintedForm”; the synonym field will be filled in automatically. Please note that in the field Name, external processing, the name should be written without spaces or punctuation marks.
Let's add external processing attributes LinkToObject and select type for him DocumentLink. Receipt of Goods and Services. To do this, in the 1C external processing metadata tree, select the item Details and press the button Add(button with green plus). The attribute properties window will open on the right side of the screen, in the field Name let's write - ReferenceToObject. IN field Type press the button with three dots.
Let's expand the branch in the type tree DocumentLink, and find the element Receipt of Goods and Services there, check the box next to it and click OK.
Let's save the external processing file to the hard drive; to do this, use the menu File -> Save, pictogram Save(blue floppy disk), or a keyboard shortcut Ctrl+S. Let's name the saved file “PrintForm”.
Creating a printed form layout
Let's start creating a layout of the 1C printing form. The layout serves as a template for the output of the printed form, so if you want your printed form to look good, you should pay attention to it.
Let’s add a new layout in the external processing metadata tree; we won’t change anything in the layout designer window and click the button Ready.
In the new layout that opens, we will create several areas necessary for displaying the printed form. All the layout areas we need will be horizontal, so to create new area should be highlighted required quantity layout lines and go to menu Table -> Names -> Assign name or use keyboard shortcut Ctrl + Shift + N, then enter the name of the region in the box. When creating a layout area, don’t be afraid to make a mistake with the number of lines; you can always add or remove them. To delete a 1C layout line, select the desired line and select the item in the context menu Delete. To add a new line to the layout, select any line of the layout and select the item in the context menu Expand.
Adding a Layout Header
First of all, let's create an area Cap, it will display the data for the header of the printed form. For this area we will need seven layout lines. Let's select them and, as I wrote above, press the key combination Ctrl + Shift + N, in the field Name write “Hat” and press the button OK.
Let's fill the layout area with the data we need. Usually, no printed form is complete without a title, so let’s create one in our layout header as well. Since in the title, in addition to the name of the printed form, we will also display the number of the document from which it was printed, we will set the text of the title in the layout as a parameter. A layout parameter is a specially designated layout cell into which various data can be output using the built-in 1C 8 language. The title should be displayed across the entire width of the printed form, so let’s decide how many layout cells will be enough for us to print on a standard landscape orientation of the sheet.
Usually thirteen or fourteen layout cells are enough, select them in the first row of the area Cap and combine into one cell ( Context menu -> Merge). After this, double-click on the resulting large cell and write the name of the parameter, in our case “TitleText”. In order for the entered text to become a full-fledged parameter, right-click on the cell and select the item in the context menu Properties. On the bookmark Layout let's find the field Filling and select the value Parameter. Parameters in the 1C layout are indicated by brackets “<>».
The heading of the printed form should stand out among the other text, so select the cell again and use the icons on the layout formatting panel to set the text alignment Centered and font size 14.
After the title text we will display it in the area Cap information about the organization, counterparty, counterparty agreement and date of receipt of goods. Since all this data is also taken from the document, we will also formalize it with parameters. In addition, before each parameter you should write explanatory text so that the user can easily understand where the organization is, where the counterparty is, etc. All these actions are similar to creating a title, so I won’t dwell on them in detail, I’ll just give a picture of what should happen in the end.
The figure shows how the layout parameters differ from regular text.
Adding a Layout Table Header
The last thing we need to create in this layout area is the table header, into which the data of the tabular part will be displayed Goods. The columns required for the table were described in the “Problem Statement” section. We will also create a table header using a combination of cells and writing text (column names). Select the borders of the table header using the tool Frame, which is located in the layout formatting panel.
Adding a table to a layout
Let's create another area in the layout - Data. The data table of the tabular part will be displayed in it Goods. For this area, we only need one line of layout. To display all the rows of the tabular part in a printed form, we will fill and display this area the required number of times. Columns in the area Data should coincide with the columns of the table header, so filling it out will not be difficult. The only difference is in the area Data we need parameters, not just text. Also note that by default, numeric parameters are formatted to the right and text parameters are formatted to the left. To select columns, you also need to use the tool Frame.
Adding a Footer to a Layout
The last layout area we need is Basement. It will display totals by quantity and amount. Creation is similar to creating an area Data, but additionally the results should be highlighted in bold.
The end result should be a layout that looks like this:
Creation of a printed form 1C. Programming
Let's start programming - this is the most important stage in creating a printed form. First of all, let's go to the external printing form object module, this is where we will program. To do this, in the main external processing window, click Actions -> Open object module.
You need to create an export function in the external printing form object module Seal().
Function Print() Export EndFunction
Please note that this feature is required for external printing forms in configurations using the regular application. All subsequent program code necessary to display the printed form will be written inside this function.
Initializing Basic Variables
Let's create a variable TabDoc, which will contain a spreadsheet document - this is exactly the printed form into which we will display the filled areas of the layout.
TabDoc = new TabularDocument;
To a variable Layout We will get the printed form layout we created. To do this we use the built-in function GetLayout(<ИмяМакета>).
Layout = GetLayout("Layout");
We will convert all areas of the layout into variables. To do this we use the layout method GetArea(<ИмяОбласти>) .
HeaderArea = Layout.GetArea("Header"); AreaData = Layout.GetArea("Data"); AreaFooter = Layout.GetArea("Footer");
Outputting the header of a printed form into a spreadsheet document
All necessary variables are initialized. Let's start filling and displaying the layout areas in a spreadsheet document. First of all, let's fill in the title of the printable form; for this we need to pass in the parameter Title Text, which we created in the layout, the text we need. To fill in the parameter values for the layout area, there is a special collection called - Options. From which through “.” you can get any parameter. In the header text we will transfer the text: “Printed form”, as well as the document number.
Header Area.Parameters.HeaderText = "Print form"+ObjectLink.Number;
We will fill in the remaining parameters of the header in a similar way; we will obtain all the necessary values for them from the details Object Reference, which contains a link to the document to be printed.
HeaderArea.Parameters.Organization = LinkToObject.Organization; HeaderArea.Parameters.Account = LinkToObject.Account; HeaderArea.Parameters.ReceiptDate = LinkToObject.Date; Header Area.Parameters.Counterparty Agreement = LinkToObject.Counterparty Agreement;
All parameters of the header are filled in, we will display it in the spreadsheet document we created, for this we use the method Output(<Область>) .
TabDoc.Output(HeaderArea);
Writing a request for a printed handicap
Let's start filling and drawing out the area Data. Creating a 1C printed form also involves writing a query; we need it to obtain tabular data Goods and prices Nomenclatures for the current date we will use Request. The 1C 8 query language is similar to SQL, or rather practically copies the capabilities of its SELECT operator, but the entire query is written in Russian. Therefore, if you are at least vaguely familiar with SQL, then you will easily understand the 1C 8 query language.
In this printed form, the request will be quite simple and many will say that it would be possible to do without it, but knowledge of the query language and the ability to use it competently is one of the main skills of a 1C programmer. Queries allow you to obtain complex data samples using fewer resources, and the query text is much easier to understand than program code written without using a query (or with minimal use of it). In addition, 1C 8 has a very good query designer that allows you to interactively assemble a query from the necessary tables.
Let's create a variable that will contain the request.
Request = New Request;
We will compose the request text using the request constructor. To begin with, let's write:
Request.Text = "";
Place the mouse cursor between the quotes and press the right mouse button. In the context menu that opens, select the item Request constructor, it will help us a lot in creating a 1C printing form. After this, the query designer window will open; it contains many tabs, but for our query we will only need four: “Tables and Fields”, “Relations”, “Conditions”, “Joins / Aliases”.
For our query we will need two tables: table part Goods document Receipt of goods and services and a snapshot of the latest information on the current date of the register Item prices.
On the left side of the designer window we find the column Database. It contains a tree of all metadata objects, let's find the ones we need. To do this, let's open the thread Documents and find the document Receipt of Goods and Services, let's open it and find the tabular part Goods, drag it into the column of the query designer Tables. You can drag in three ways: by dragging, by double-clicking on the table, or by selecting it and clicking the “>” button. Let's open the thread Information Registers and find a table there PricesNomenclature.ShortcutLatest, also drag it into the column Tables. These two tables are enough for our query.
Let's select the fields we need from the resulting tables. To do this, in the column Tables let's open the table and find the fields: Nomenclature, Amount, Price, Quantity and drag them to the third column of the constructor - Fields. Let's expand the table , let's find the field Price and also drag it to Fields.
The structure of the tables and fields of our request is ready, now let’s move on to the conditions. We need the tabular data Goods were not taken from all receipts, but only from the one that we print. To do this, we will impose a condition on the table Receipt of GoodsServicesGoods. Let's go to the “Conditions” tab of the query designer. In the column Fields the tables we selected earlier are located, for the condition we will need a field Link from the table Receipt of Goods and Services Goods, Let's drag it into the Conditions window.
In 1C queries you can use parameters; they are needed to transfer data to the request. For example, if we want to limit the selection of documents to a specific document, then we can use a parameter to pass a link to this document to the request and use this parameter in the condition. This is exactly what we will do in our request.
After the window Terms we added a field Link, the query designer itself will create a parameter with the same name and place it after the “=” sign. This parameter can be renamed if desired. In the request text, parameters are marked with the “&” sign, but in this case this is not necessary, since it is assumed that the second part of the condition contains a parameter, you just need to remember this. How to pass a value to a 1C request parameter will be discussed below.
Since in the request we are not using a complete table of product prices, but a virtual one (a slice of the latter in this case), we need to set the conditions for the formation of this virtual table, in our case this is the cut-off date and the condition for the type of prices (prices that have a strictly defined price type is the one that is specified in the receipt document that we print).
To fill in the parameters of the virtual table, go to the tab Tables and fields query constructor, in the column Tables select the table PricesNomenclatureCuttingLatest and press the button Virtual Table Options, located at the top. In the window that opens, in the field Period you should set a parameter to which the date on which the price cut will be made will be passed. In our case, this will be the current date (that is, today), so we will call the parameter “&CurrentDate”. In the conditions field we will write the conditions for the price type, we will also pass it in the parameter, which we will call “&TypePrice”. The resulting condition will look like this (where TypePrice- register measurement Item prices):
PriceType = &PriceType
The virtual table parameters are filled in, click the button OK.
Now that we have limited the selection to only the document we need, let's create connections between the query tables. If this is not done, then the prices from the PricesNomenclatureSliceLast table will not be associated with the item from the receipt. Let's go to the tab Connections query designer. Let's create a connection across the field Nomenclature between our two tables. To do this, press the button Add, in the field Table 1 select a table Receipt of GoodsServicesGoods, and in the field Table 2 - PricesNomenclatureSliceLast. In the communication conditions, select the fields Nomenclature from both tables.
It should also be noted that in the query selection we need to get all the rows from the tab part Goods and prices only if they are available on the current date for the document price type. Thus, the tabular data Goods are mandatory, but price breakdown data is not available. Therefore, in the relationships between these tables it is necessary to use the so-called LEFT JOIN, and the left (or required) table will be Receipt of GoodsServicesGoods, and the right (or optional) PriceNomenclatureSliceLast. In order for the left join of query tables to work as I described above, you need to check the box All after the field Table 1.
The request is almost ready, all that remains is to work a little on the field aliases. Let's go to the bookmark Unions/Aliases and set an alias for the field PricesNomenclature Slice Latest.Price. The nickname name will be - PriceAsToday, it is needed so that the names of the query selection fields and the names of the parameters in the printed form layout match.
The work in the query designer is now complete, click OK. After the designer window closes, you will see that the line with the request text is filled in and looks like this:
Request.Text = "SELECT | Receipt of GoodsServicesProducts.Nomenclature, | Receipt of GoodsServicesProducts.Amount, | Receipt of GoodsServicesProducts.Price, | Receipt of GoodsServicesProducts.Quantity, | PricesNomenclature Slice of Latest.Price AS PriceToday | FROM | Document. Receipt of GoodsServices.Goods AS Receipt ProductsServicesProducts | LEFT CONNECTION RegisterInformation.PricesNomenclature.SliceLast (| &CurrentDate, PriceType = &PriceType) AS PricesNomenclatureSliceLast | ON Receipt of GoodsServicesItems.Nomenclature |
Executing the request
Let's pass the necessary parameters to the request; for this we will use the request method SetParameter(<ИмяПараметра>,<Значение>).
To get the current date, use the built-in function CurrentDate(), it returns the computer's date and time.
Let's run a query to get a sample with the data we need. To do this, first use the request method Run(), and then the method Choose().
Select = Query.Run().Select();
Filling out the printed form table
As a result, in the variable Sample will contain a selection of query results, you can navigate through it using the method Next(), and to go through the whole thing you need a loop Bye. The design will be as follows:
While Select.Next() Loop EndLoop;
It is in this loop that we will fill and display the layout area Data. But first, let's initialize two variables of numeric type. In them we will collect the totals by quantity and amount that we need to display in the area Basement.
TotalSum = 0; TotalQuantity = 0;
Inside the loop we will fill the area Data data from the current selection element into variables TotalAmount And TotalQuantity add sum and quantity values, and finally, display the area in a spreadsheet document using the method already familiar to us Output(). Since the names of the fields of our request completely coincide with the names of the area parameters Data, then to fill we will use the built-in procedure FillPropertyValues(<Приемник>, <Источник>), which copies property values<Источника>to properties<Приемника>.
While Selection.Next() Loop FillPropertyValues(AreaData.Parameters,Selection); TotalSum = TotalSum + Sample.Sum; TotalQuantity = TotalQuantity + Sample.Quantity; TabDoc.Output(AreaData); EndCycle;
Outputting the footer of a printed form into a spreadsheet document
It remains to fill and display the last area of the layout - Basement. We have already prepared the data for filling, filling and withdrawal are carried out according to the same scheme.
AreaFooter.Parameters.TotalQuantity = TotalQuantity; AreaFooter.Parameters.TotalSum = TotalSum; TabDoc.Output(AreaFooter);
Spreadsheet document completely filled out, all that remains is to display it on the screen so that the user can view the printed form and print it if necessary. But in typical 1C 8 configurations, the procedures of special modules are responsible for the output of external printed forms. Therefore, it is enough to return from the function Seal() completed spreadsheet document.
Return TabDoc;
At this point, the programming stage is completed and the creation of the 1c printing form is almost complete. Full text of the function Seal() I won’t give it here, you can look at it in the printable file, which you can download at the bottom of the article.
Creation of a printed form 1C. Auto-registration options
When connecting an external printing form to the database, the system does not automatically determine which document or reference book the printing form is intended for; you have to select it manually. And if another person wrote the printed form, and you are only tasked with connecting it, then the choice may become ambiguous. In order to avoid such problems, it is necessary to create a layout with auto-registration parameters in all external printed forms. If it is created and correctly formatted, the system automatically determines which document or reference book the printed form is intended for.
It is done as follows:
- In external processing we create a new layout. We call it “Settings_Auto-Registration” (it’s important not to make a mistake!).
- In the first cell of the layout we write Documents.(or Directories.) and the name of the document to which you need to connect the printed form.
Connecting an external printing form to the base
- Start 1C 8 in mode Enterprise;
- Go to menu Service -> Additional reports and processing -> Additional external printed forms;
- Click the button Add;
- In the window that opens, click the icon Replace external processing file;
- If you have created auto-registration parameters, then we agree to use them;
- If you have not created auto-registration parameters, then in the tabular part Printing plate accessory add required document or reference book;
- Press the button OK.
After this, the external printing form will be available in the menu Seal document Receipt of goods and services. The creation of the 1C printed form can now be considered complete.
Life goes on, legislation changes, the developer releases configuration updates and we again have a choice: install the update ourselves or again call the programmer to “install a new release”...
Let's get acquainted with the mechanism for changing printing forms without changing the configuration.
In the practice of every accountant using 1C, there has ever been a need to modify the configuration for themselves: someone adjusted the accuracy of the price or amount in the invoice, someone inserted a logo and adjusted appearance invoice. Everything would be fine, but over time a great many of these changes accumulate and when the time comes to update the release, a dilemma arises: either lose all the changes made, or call a programmer to transfer all the changes to the new release (of course for an additional fee). How can this be? To somehow simplify updating configurations, the developers created a new mechanism: “External processing, printed forms, processing for filling out tabular parts.” Today we will look at only part of this mechanism - printing forms.
Any subject is best learned by example. Let's set ourselves the following task: add to the configuration the ability to print an invoice (document “Sales of goods and services”) with our company logo. In addition, it is necessary that in the header of the document the inscriptions "supplier" And "buyer" were highlighted in bold and finally, it is necessary that at the bottom of the document there is a place for the signature of the security service that authorized the shipment.
Let's introduce two additional conditions:
- The new printed form should replace the old form "Invoice"
- The configuration cannot be changed, since we want to use auto-update of the configuration in the future
Well, what's the task? Seems too complicated? Well, the more complex it is, the more interesting it is, and the more you want to solve it. Then get to work.
We launch our database in Configurator mode. Open the configuration by selecting the command in the main menu "Configuration > Open Configuration". We will not change the configuration itself under any circumstances. We will use it as a prototype. We will do the main work here, but we will edit external processing. We create external processing with a command in the main menu "File > New". Selecting the type of document "External processing". For the first processing, let's set a name "Branded Invoice"
Important! The processing name must not contain spaces, just like variable names.
Now let's do a little "plagiarism". Let's copy the layout "Invoice" from document "Sales of Goods and Services". To do this, we will find it in the branch "Documents" configuration tree. Expand this thread by clicking on the icon «+» and find the layout we need "Invoice"(it's in the thread "Layouts"). In order to copy this object, you need to select this layout in the tree and run the command "Edit > Copy"(the same action occurs with the combination CTRL+C). Now let's go to the processing we created, select a label in the tree "Layouts" and in the main menu select the item - "Edit > Paste" (CTRL+V). The result should look like Figure 1.
Now double-click to open the layout.
What is a "layout"
Let's say a few words about the purpose of the layout.
Layout– storage location "building blocks", areas from which, like bricks, a tabular document is built, which we are accustomed to calling a printed form. Areas are defined using horizontal and vertical sections or their intersections. Our layout has only horizontal sections: “Header”, “Supplier”, “Buyer”, “Table Header”, “Row” (see Fig. 2). An area is a set of cells. As in MS Excel, cells can be merged, text and background colors, fonts, and so on can be changed. All cell settings can be viewed and changed in the cell properties window. You can call the settings window by right-clicking on the cell and selecting the context menu item "Properties"(the same result is achieved by the keyboard shortcut Alt+Enter).
A cell can contain one of three types of values:
- text– a value of this type will be printed in the same form;
- parameter– a cell of this type contains the name of a variable whose value will be printed.
- sample– cells of this type are a combination of the first and second options. The cell can contain text and variables. In order for a program to distinguish text from a variable, variables must be enclosed in square brackets: "Today is [Date]".
Important! The table editor displays the values of cells of the second and third types in triangular brackets. In Figure 2 there is a cell with text "Buyer"- looks like text, and to the right of the cell "Buyer's Presentation"- parameter.
Why am I telling all this? Now you know in which cells you can easily change the contents, and in which it is undesirable to change anything, since you will need to make changes to the printing algorithm.
Let us now return to our task. We created the processing, copied the layout and are ready to modify it to suit ourselves. First, let's take a closer look at it.
What's included in the printable layout
The layout structure of all documents is very similar. Having carefully examined one document, we can understand others. First section "Title". When this section is displayed, a document header will be generated, consisting of the type, date and document number. It is followed by sections "Supplier" and "Buyer", in which the program will display information about the supplier and buyer, respectively. Next is a more interesting section "Additional Information", which developers use to display other information on the document, for example, information about the contract with its number and date. The peculiarity of this section is that it can be displayed many times, and each time it can contain different information. What exactly to print and when is described in the printing algorithm.
This completes the header of the document. The header is usually followed by a tabular section. Interestingly, the layout describes two options for displaying the tabular part: "Table Header", "String" and "HeaderTablePlaces" And "StringPlace". Depending on whether your column is filled or not "Mest" in the document, the first or second option for displaying the tabular part of the document will be used. The curious reader has probably already wondered: why in the header output section "Price" And "Sum" are placed in triangular brackets as if they were variables? That’s right – these are variables in which, depending on the document settings, the inscription will be displayed "Price", "Price with VAT" or "Price without VAT" and similarly for the amount.
Well, below in the layout there are sections with the help of which the results of the document and signature are displayed.
Editing the layout
It would be nice to place the logo above the information about the supplier and buyer. I suggest editing the layout area "Title". It is necessary to reduce the size of the cell containing the contents "TitleText". This cell consists of several merged cells. We change the size as follows:
- Let's carefully copy the contents of the merged cell "TitleText"(to do this, you need to select the cell and use the command “Edit > Copy” or keyboard shortcut CTRL+C)
- Having selected this cell, select the item in the main menu "Table - Merge", which will lead to the opposite effect - the merged cell will be split into many original cells
- Now let's select a smaller number of cells - instead of cell 2 of column, we will start merging from column 6, ending it at column 32 - and click on the button again "Merge"
- Team "Edit > Paste" (CTRL+V) insert the contents of the previous merged cell into the new merged cell
- We simply clear the freed cells in columns 2 – 5 (select them and press the Delete key)
Now you can insert a picture with a logo into the free space. To do this, select the item in the menu “Table > Pictures > Picture...”. Find the file with our logo on the disk and click “ OK" Now let's move the image to the free space. The result should look like in Figure 3.
Now let’s highlight the values in the cells in bold "Supplier" And "Buyer"(Fig. 4). To do this, find the parameter in the cell properties "Font" and set the style to bold.
And finally, it remains to add the signature of the security service. We will post this information in the section "Signatures". To get space for signatures you need to expand the section. Select line 37, right-click on it and select "Expand", and so on twice. In one of the added lines we will place a place for the signature of the security service. As a result, everything should look like in Figure 5.
Important! In a typical configuration, two languages are used: Russian and Ukrainian. The layout stores the text representation in both languages (the cell design is general). In order to enter the Ukrainian version of the inscription we added, you need to go to the cell properties and to the field "Text" press the button "search". A window will open for entering text representations in different languages (Fig. 6).
How to ensure printing
So, the layout is ready. Now is the time to work on the algorithm for printing it.
In order for us to painlessly integrate this layout into the configuration and use it, the processing that we created must satisfy the following conditions:
- You need to create props in processing "Object Link" with type "AnyLink"
- You need to create a procedure in the processing module "Print() Export" no parameters and must be specified keyword "Export"
The first point is needed so that the printing algorithm knows where to get data for printing, and the second is the printing algorithm itself. Let's fulfill these conditions.
In the window panel, select the window for editing our processing (in Figure 7). A window will open with a tree of objects for our processing. Selecting a branch "Details" and press the button "Add",. The attribute properties window will open. Let's enter the name - "Object Link" and indicate the type "AnyLink". Now we can move on to the text of the print module. We won’t write it from scratch; instead, we’ll copy it from the document "Sales of Goods and Services".
To do this, find in the configuration tree among the documents "Sales of Goods and Services", right-click on it and select "Open object module"(see Figure 8).
This will open the document module. We need the first function "PrintDocument". Its text must be selected and copied. It is very convenient to highlight the text of a function when it is collapsed, but you must also highlight the line below it, otherwise you risk copying only the title.
See in Figure 9, we have highlighted the title and the line below it. After that, copy it to the clipboard. Main menu "Edit > Copy" (or CTRL+C).
We have memorized the text on the clipboard, now let’s move on to our processing again "Branded Invoice". Click on the button "Actions > Open Object Module"(Fig. 10).
Paste the copied text: "Edit > Paste" (or CTRL+V).
Now it is necessary to slightly edit the copied text, since it was written for printing a document from the document itself, and we are collecting it from external processing. To do this you need:
- Rename function to "Print"
- Replace "ThisObject" on "Object Link"
- Replace "ThisObject" on "Object Link"
- Replace "Organization Bank Account" on “Link to Object.Organization Bank Account”
- Replace "Products. Summary" on "LinkToObject.Products.Total"
For these actions you can use the main menu item "Edit > Replace".
After this, you must check for syntax. There is a magic combination for this: CTRL+F7. As a result, the following message should appear: "No syntax errors found!"
Well, with this we have completed all the dirty work. Now we can save the results of our work in a file, for example "BrandedInvoice.epf". To do this, you need to make the window for this processing active and save it using the main menu of the program "File > Save As...". Processing file name – "BrandedInvoice.epf"(it will be offered by default). You can save it temporarily to your desktop so you can find it faster later.
Important! As you have seen, we did not make any changes within our configuration. For all the actions described above, you don’t even need to remove it from support (that is, enable the ability to change).
Connecting external processing to the configuration
Now we can connect processing to our invoice. To do this, launch in mode. Go to the menu "Service", where there are three points related to the mechanism “External processing, printing forms, processing for filling out tabular parts”. In our case, we only need the item "External printing forms"(see Fig. 11).
This will open the directory. "External processing", with selection by type "printed forms". It will store a list of all external printed forms, indicating which documents they are for and in what cases they need to be shown.
Important! The processing itself will be stored in the database along with other data, that is, after saving the processing inside the database, we will not need an external file.
We need to create a new element in the directory. Click Insert. Now let's look at the contents of the element. We add meaning to the name brief description the essence of this form, for example, "Company invoice". Like any other directory, it also has a code. Let's leave it as default. The type attribute is filled in by default and cannot be edited – "Print form". And the last element of the header is a comment. Here, as usual, there is more detail about the purpose of the printing form. In addition to the header, the elements of this directory have two bookmarks. The second contains information about restricting access rights to this processing. This topic is beyond the scope of this article (we will talk about this and other settings of access rights without modifying the configuration in one of the upcoming issues).
Let's take a closer look at the first tab.
The tab contains four columns. Object representation– the type of document for which we would like to use our printing form,
Selection– a condition under which this printed form should be available. For example, we redesigned the printed form of the invoice and translated it into English. And we want for clients from the folder "European" instead of a standard printed form "Invoice" was published new form, on English. To do this, you can use the column "Selection". An example of such selection is shown in Figure 13.
But in our task no selections are needed.
Printable Form File– indicates the file from which to take the layout and printing procedure. In this cell you need to select the file we saved on the desktop.
Replaceable printing plate– if we want the printed form we created to replace one of the standard ones for this document, then we need to indicate which one needs to be replaced. If there is nothing to choose, an additional printed form will appear.
In our case, we need to "Branded Invoice" was printed instead of the usual invoice. To do this, select in this field "Invoice".
Now let's save this element. And open any invoice.
It should look like shown in Figure 14.
Well, this concludes the task that we set for ourselves at the beginning of the article. We believe that we were able to illustrate the possibilities that the use of the mechanism opens up for the user external treatments.
To consolidate your skills, you can try to independently add to the configuration an additional printed form “To the warehouse” for the document “Receipt of goods and services”, which would repeat the usual invoice, but without prices and amounts, and would also contain fields for entering the accepted quantity.
It's no secret that, although in our time everything more companies are switching to electronic document On the contrary, the old saying “Without a piece of paper you...” does not lose its relevance. It so happens that for some reason the inspection authorities are primarily interested in paper documents. Therefore, if you actively use for financial control program 1C: Accounting or Enterprise, it is important to know how to print an electronic document created using the program.
Printed forms in 1C allow you to transform an electronic document into a printed version.
For this, the developer has provided an excellent tool - Print Designer. With its help, you can create documents in which you can specify any data you need, and not just a few standard forms. This is especially true for those documents that do not have a strictly regulated form, which cannot be changed under any circumstances. This, in particular, may include an act of completion of work, some invoices or payments.
In this guide, we propose to understand the capabilities of the Print Designer, consider what types of printing forms there can be and how they differ from each other. We will also show with an example how to print the created form.
First, it’s worth understanding what, in general, a printed form is in 1C 8. This is a 1C spreadsheet template (like Excel), in which some variable rows are specified, filled with data from the program when creating a document.
Printing forms come in two types:
- Internal (built-in). They are stored in the program configuration, so it is better not to change them, as problems may arise later during the update.
- External - stored separately from the program settings. And with their help, you can create and prepare for printing a document of almost any complexity, without affecting the configuration of the 1C 8 program.
How to choose already prepared layouts? After you carry out an incoming or outgoing operation, for example, writing out a report of completed work, you click the “Print” button to print the documents. The list displays a list of printable forms that are already filled with entered data about the transaction performed and your company. By clicking the type of document you need, you open a window preview so that you can verify that the information filled in is correct. The print button prints the document to the printer.
With the basics out of the way, let's figure out where all your printables are stored. Let's move on to the next question.
Where are printed forms stored?
You can view the built-in printed forms both in the configurator mode and in the normal enterprise mode. In the first case, you need to click the corresponding button in the start window when starting the program. You will see the program menu, find the “Sales of Products and Services” branch, which contains the “Layouts” item. It often contains only two items - “Invoice” and “Act”. Where is everyone else then, since the list is much more extensive? They're just hiding somewhere else. You need to open the “General” branch - “ General Layouts", almost all layouts are stored in it.
In the second case, you need to go to the menu section “Administration” - “Print forms, reports and processing” - “Print form layouts”. It will display all document layouts. It is noteworthy that they can be edited in the same menu.
As for external forms, you first need to either create them through the configurator mode, or by downloading a ready-made file, and then connect them to the “Administration” menu - “Printed forms, reports and processing” - “Additional reports and processing”. We'll talk about this a little later.
Creating a simple form using the built-in Print Designer
Such a printed form does not imply the possibility of deep editing, since this will entail a change in the program configuration, as well as further difficulties when updating it. However, if you are completely satisfied with the standard shape or want to delve into the intricacies of creating an external shape, this method is completely suitable for you.
- First of all, launch into the Configurator mode, find the document you need, for example, Sales of Products and Services, in the document properties go to Actions - Designers - Print Designer.
- When prompted for a work option, select Regular Forms.
- Give the new layout a name, for example, “Print Invoice.”
- Select the details that you would like to see in the header of the document. Moreover, they must be selected in the order in which they will be displayed. To select, you need to highlight the item in the left column with the cursor and press the arrow in the middle of the screen so that the details appear in the right column.
- Mark the details to be displayed in the table section. The selection of details follows the same principle as in the previous paragraph.
- In the same way, select the details of the lower part of the document.
- At the final stage of creation, select whether you want to print immediately without preview, whether you need to protect the table, and then confirm the creation of the form with the OK button.
Creating an external printing form
Forms created through the Print Designer can be compared to a visual software editor, when you do not enter all the code manually, but only compose it from the proposed elements. The external form is a file with manually written program code, which describes the procedure for displaying data on the screen. This is what allows you to edit the printed form however you like, specifying absolutely any data in any sequence.
An additional advantage is that, even if you do not understand or simply do not want to understand the intricacies of 1C 8 programming, you can entrust this procedure to professionals. They will be able to prepare the required form for you and provide it to you as a ready-made file, which you can only activate with a few clicks of a button.
Now let's talk more about the procedure itself. Let's look at the example of creating an “Invoice” layout for the document “Sales (acts, invoices)”.
- Open the 1C 8 program in Configurator mode.
- Click File - New - External Processing, give it a name (it should not include spaces), then click Actions - Open Object Module.
- In the input field that opens, enter the following code (values that can be changed to your own are highlighted in yellow):
Function InformationOnExternalProcessing() Export
Registration Parameters = New Structure;
ArrayDestinations = New Array;
Array of Assignments.Add("Document.Sales of Goods and Services"); //Specify the document for which we are making an external print. form
Registration Parameters.Insert("View", "PrintForm"); //maybe - PrintableForm, Filling Object, Additional Report, Creating Related Objects...
Registration Parameters.Insert("Destination", Array of Destination);
Registration Parameters.Insert("Name", "Order for sale of goods"); //name under which the processing will be registered in the directory of external processing
Registration Parameters.Insert("SafeMode", FALSE);
Registration Parameters.Insert("Version", "1.0");
Registration Options.Insert("Information", "This printable form was created as a sample");
CommandTable = GetCommandTable();
AddCommand(CommandTable, "External Order", "ExternalOrder", "CallServerMethod", True, "MXL Print");
Registration Parameters.Insert("Commands", CommandTable);
ReturnRegistrationParameters;
EndFunction // Information ABOUT External Processing()
Function GetTableCommand()
Commands = New ValueTable;
Commands.Columns.Add("View", New TypeDescription("Row"));//what the description of the printing form will look like for the user
Commands.Columns.Add("Identifier", New TypeDescription("String")); //print form layout name
Commands.Columns.Add("Usage", NewTypeDescription("Row")); //Call ServerMethod
Commands.Columns.Add("ShowAlert", NewTypeDescription("Boolean"));
Commands.Columns.Add("Modifier", NewTypeDescription("Row"));
Return Team;
EndFunction
Procedure AddCommand(CommandTable, View, Identifier, Usage, ShowAlert = False, Modifier = "")
NewCommand = CommandTable.Add();
NewCommand.View = View;
NewCommand.Identifier = Identifier;
NewCommand.Use = Use;
NewCommand.ShowAlert = ShowAlert;
NewCommand.Modifier = Modifier;
EndProcedure
- Save the layout for printing as a file in any folder on your hard drive, name it appropriately.
Insert into the same document the procedure for starting printing from the program menu (commands highlighted in yellow must match the line):
Add Command(Table of Commands, “External Order”, “External Order”):
Procedure Print(Array of Objects, Collection of PrintForms, PrintObjects, Output Parameters) Export
Print Management.Output TabularDocumentIntoCollection(
Collection of Printing Forms,
"External order"
"External order"
GeneratePrintForm(ArrayofObjects, PrintObjects);
EndProcedure // Print()
- Insert a layout for filling out the printed form by clicking on the name of the external form in the lower left corner and selecting “Layouts” - “Add” - “Spreadsheet Document”, give it a name. After that, fill the spreadsheet with the necessary data. For example:
- Order for product No. [Realization Number] from [Realization Date] - right-click - Properties - Layout - Filling - Template.
- Create the columns that you want to appear in your document.
- Select the entered cells, click Table - Names - Assign a name - enter the name “Header”.
- Copy the row with the table headers, select them, right-click - Properties - Layout - Filling - Parameter.
- Select a line and name it, for example, “StringTCH”.
- Create a footer: write Total, the cell in which the total amount should be displayed, name it TotalTotal, select “Parameters” in the properties.
- Specify the person responsible, and in the properties of the cell to display the last name, specify “Parameters”.
- Select the bottom rows and name the range "Footer".
- Now in the input window, enter the function for generating a printed form:
Function GeneratePrintForm(LinkToDocument, PrintObjects)
TabularDocument = New TabularDocument;
TabularDocument.Name of Print Parameters = “PRINT_PARAMETERS_Invoice for Payment to VRTU”;
Processing Layout = GetLayout("Payment InvoiceExternal");
//fill the header
AreaHeader = ProcessingLayout.GetArea("Header");
AreaHeader.Parameters.DocumentNumber = LinkToDocument.Number;
AreaHeader.Parameters.DocumentDate = LinkToDocument.Date;
AreaHeader.Parameters.OrganizationName = LinkToDocument.Organization.Name;
//output the header in a spreadsheet document
TabularDocument.Output(HeaderArea);
//fill in the PM lines
RowArea = ProcessingLayout.GetArea("ROW");
For Each Current Line From Document Link.Products Cycle
FillPropertyValues(RowArea.Parameters, CurrentRow);
TabularDocument.Output(RowArea);
EndCycle;
//fill the basement
AreaFooter = ProcessingLayout.GetArea("Footer");
AreaFooter.Parameters.QuantityTotal = LinkToDocument.Products.Total("Quantity");
AreaFooter.Parameters.AmountTotal = LinkToDocument.Products.Total("Amount");
AreaFooter.Parameters.ResponsibleName = LinkToDocument.Manager.Name;
//output the footer to a spreadsheet document
TabularDocument.Output(AreaFooter);
TabularDocument.AutoScale = True;
return TabularDocument;
EndFunction
- Save your changes to the document.
- Now you need to activate the created form. To do this:
- Go to “Administration” - “Printed forms, reports and processing” - “Additional reports and processing”.
- Click the “Create” button, select the external form file in Explorer, confirm your entry with the “Save and Close” button.
- To check, go to Sales - Sales (acts, invoices), click the “Print” button, select your form and check that it is filled out correctly.
- Print the document if necessary.
Conclusion
We looked at an example of creating a printable form through the Print Designer and through the tool for creating external forms. We hope everything works out for you. Leave your questions in the comments.
2016-12-01T12:56:42+00:00A wonderful opportunity has appeared in 1C: Accounting 8.3 (edition 3.0). Now a user in 1C:Enterprise mode can easily edit printed form layouts.
When might this be useful? Well, for example, there is some printed form, say, “Demand-invoice” in which you make some changes every time after printing it. Change the font, reprint the fields, remove unnecessary things.
So why do this every time?! If we can make these changes to the layout of the printed form once, the program will always output the printed form as we need.
Below, step by step, I will show you how to change the layout of the “Demand-invoice” printed form. We will add a new field there: “Responsible”.
1. Create a printable form (click the “Print” button) and click the “More” -> “Change Layout” button in the form that opens (on the right):
2. The printable layout will open. Make the necessary changes to it, but be careful that it doesn't work out like this. I’ll say right away that fonts and field sizes can be changed absolutely, but deleting existing fields (especially those in<угловых скобках>) not worth it. If you want to hide a field in<угловых скобках>, just make it invisible (color or size), but it should remain on the form, since it is required by the 1C program code.
3. We will add the "Responsible" field and click the "Record and Close" button.
4. The printing form was reshaped in a new form as we wanted.
If, after changing the printing form, it stops working, then you.
Sincerely, Vladimir Milkin(teacher and developer).
This article describes how to connect an external printed form to a 1C database using the example of the “Trade Management 11.2” configuration
The “Trade Management 11.2” configuration is a configuration on “MANAGED” forms!
Our instructions “show” how to connect an external printing form to information base 1C with configuration on “MANAGED” forms, namely:
- "Accounting 3.0"
- "Trade Management 11.2"
- "Salary and personnel management 3.1"
- "Comprehensive automation 2.0"
- "Control small company 1.6"
- "Retail 2.2"
- and other similar configurations.
In order to connect an external printing form in 1C we will need to go through 11 steps.
1 — Menu “Master data and administration” (In other configurations, such as in Enterprise Accounting 3.0, it may be called simply “Administration”). 2 — Select “Printed forms, reports and processing” (see figure below ↓)
3 — Expand the “Reports and Processing” submenu (In other configurations, such as Enterprise Accounting 3.0, there may not be such a submenu, so we immediately move on to the next step). 4 — Check the “Use of additional reports and processing” box. 5 — Go to the section: Additional reports and processing. (see figure below ↓) ()
6 — Click the “Create” button. (see figure below ↓)
In new versions of 1C (starting from August 2016), the program has a built-in warning mechanism about the danger of using unknown external processing that may contain “viruses”; in earlier versions of the program the warning will not appear! If this occurs, then to connect an external printing form it will be necessary - 7 — click the “Continue” button. (see figure below ↓)
8 — Select the directory in which the processing is located. 9 — Select it (the processing we need). 10 — Click the “Open” button. Or, instead of steps 9 and 10, you can simply double-click on the external printed form we need in the selection window. (see figure below ↓)
If we need to add placement for the added processing (For example, this is a Universal Contract Form from our website and we need the command to print this form to be displayed in some object in which it is not initially displayed) - 11 — click on the placement line (“Place in:”, maybe “Placement:”) and select the necessary directories and documents. 12 — We complete the steps to connect an external printing form by clicking the “Record and close” button. (see figure below ↓)
That's it! Congratulations! External printing plate is connected! Did we do everything right? Let's check...
Before Recording and closing, we noticed that this external printed form is located in the document Sales of goods and services, which means that we can open printing options for any document of the type: “Sales of goods and services.” press the “Print” button and see that a window for selecting printed forms has appeared, among them there is - 13 — external printing form connected by us (see figure below ↓)
Now that’s it for sure. We hope that this article was useful to you.