1C Incoming Invoice#

Let's consider an example of a Robot that creates an incoming invoice in the 1C program. The source data for this project is the file "Supplier Order". To ensure the robot works correctly, the 1C application must be launched beforehand.

This project demonstrates data loading from PDF or Excel. To see how the work with PDF occurs, you need to connect the "Start Process" block and the left block "Get File Path".

To check the work with loading from an Excel file, you should connect the "Start Process" block and the right block "Get File Path".

The robot project consists of four diagrams and two files: pdf and xlsx. Each file has its own diagram for data loading.

The main diagram of the project looks like this (for convenience, the blocks of the diagram are numbered):

  1. Block "Start" (any diagram starts from this block).
  2. Block "Launch Application" launches the 1C program. The following properties are specified for this block:
  • Path to the application (the path to the application being launched or the name of a standard application, e.g., cmd.exe);
  • Parameters (command line parameters required to launch the application);
  • Wait for launch (pauses the script until the specified application is launched); Wait time (specified in seconds and ignored if the "Wait for launch" property is not selected).
  1. Block "Get File Path" retrieves the full path to the file with the specified name. The following properties are specified for these blocks:
  • Path to the folder (the path to the folder where the required file is located; if this property is empty, the folder where this project is located will be used);
  • File name (the name of the file along with its format).

In this case, two "Get File Path" blocks are used in parallel: one for the pdf file format and the other for the xlsx file format.

  1. Block "Process" allows creating scenarios consisting of several diagrams. The execution of the scenario will continue from the "Start" block of the specified project diagram. The execution of the scenario will return to the current block and continue in the current diagram as soon as the "End" block in the external diagram is reached. For the "Process" block, the property "Diagram Name" is specified (the name of the diagram file where the scenario will continue).

In this case, as above, two "Process" blocks are used in parallel: one for loading data from the pdf file and the other for loading data from the xlsx file.

  1. Block "Process" located below allows creating another scenario that is common to the two scenarios described above. This process is responsible for adding the invoice in 1C. For the "Process" block, the property "Diagram Name" is also specified (the name of the diagram file where the scenario will continue).

Diagram "Loading Data from PDF"

  1. Block "Start" (any diagram starts from this block).
  2. Block "Log" allows outputting arbitrary messages and/or variable values to the log during the execution of the robot's scenario. For this block, the property "Value" is specified. A text constant is indicated in quotes, and the variable name starts with the symbol $. That is, this block logs a message about loading the selected file specified by the variable.
  1. Block "Execute Expression" starts the execution of one or more expressions in a language compatible with PowerShell. In this case, two expressions are used.
  1. Block "Extract Table" allows extracting the specified table from the pdf file. The following properties are specified for this block:
  • File name;
  • Page number (the page number from which the text will be extracted from the table);
  • Table number on the page (the number of the table on the page from which the text needs to be extracted).
  1. Block "For Each Loop" iterates through all rows of the data table.
  1. Block "Get Text from Page" allows reading text from the specified page of the pdf file. The following properties are specified for this block:
  • File name;
  • Page number (the page number from which the text will be extracted);
  • Result (returns the extracted text from the page).
  1. Block "Find Substring Between Two Substrings" allows finding a substring in the text that is located between two other substrings. There should be as many of these blocks as there are substrings to find. In this case, two "Find Substring Between Two Substrings" blocks are used: for the substring "Executor" and the substring "Order". The properties of the blocks are specified as follows:
  • Text (input string);
  • Left part (left search substring);
  • Right part (right search substring).
  1. Block "Condition" checks the specified condition for truth, after which the execution of the scenario continues towards the "Yes" output (if the condition is met) or towards the "No" output (if the condition is not met).

The condition is written in the format: "variable" equals (==)/ greater than (>)/ less than (<) "value".

For example: $a == "Hello", that is, if the value of the variable $a is equal to "Hello", then the output is "Yes", otherwise the output is "No".

$Result > 5, that is, if the value of the variable $Result is less than 5, then the output is "Yes", otherwise the output is "No".

In this case, the condition is set as: $Row[0] == $index, that is, if the value of cell 0 is equal to the variable $index, then the output is "Yes", otherwise the output is "No".

  1. Block "Add Row" allows adding a row to the data table. In this case, the following properties are specified:
  • Table (the data table to which the row is added);
  • Row number (returns the number of the added row, numbering starts from 0).
  1. Block "Write Value to Cell" allows writing a value to a cell in the data table. In this case, three such blocks are used for different variables: $Row[2], $Row[3] and $Row[5].
  1. Block "Execute Expression" starts the execution of one or more expressions in a language compatible with PowerShell. In this case, one expression is used.
  1. Block "Execute Expression" starts the execution of one or more expressions in a language compatible with PowerShell. In this case, two expressions are used.
  1. Block "End" (this block completes the execution of the scenario or returns the subprocess diagram to the main process).

Diagram "Loading Data from XLSX"


  1. Block "Start" (any diagram starts from this block).
  2. Block "Log" allows outputting arbitrary messages and/or variable values to the log during the execution of the robot's scenario. For this block, the property "Value" is specified. A text constant is indicated in quotes, and the variable name starts with the symbol $. That is, this block logs a message about loading the selected file specified by the variable.
  1. Block "Open Document" allows opening an Excel document. The following properties are specified for this block:
  • Path to the file (the path to the Excel document that needs to be opened);
  • Link to Excel (returns a link to the process of handling the Excel document);
  • Link to document (returns a link to the opened Excel document currently being worked on).
  1. Block "Get Cell Value" allows reading a value from a cell in the Excel document. In this case, two "Get Cell Value" blocks are used for different rows and columns. The following properties are specified for this block:
  • Link to document (returns a link to the opened Excel document currently being worked on);
  • Sheet (the ordinal number or name of the sheet where the required cell is located);
  • Row (the row number where the required cell is located);
  • Column (the column number where the required cell is located);
  • Result (returns the content of the cell of the same data type as in the Excel document).
  1. Block "Find Substring Between Two Substrings" allows finding a substring in the text that is located between two other substrings. There should be as many of these blocks as there are substrings to find. In this case, two "Find Substring Between Two Substrings" blocks are used: for the substring "Executor" and the substring "Order". The properties of the blocks are specified as follows:
  • Text (input string);
  • Left part (left search substring);
  • Right part (right search substring).
  1. Block "Execute Expression" starts the execution of one or more expressions in a language compatible with PowerShell. In this case, one expression is used.
  1. Block "Get Cell Value" allows reading a value from a cell in the Excel document. The following properties are specified for this block:
  • Link to document (returns a link to the opened Excel document currently being worked on);
  • Sheet (the ordinal number or name of the sheet where the required cell is located);
  • Row (the row number where the required cell is located);
  • Column (the column number where the required cell is located);
  • Result (returns the content of the cell of the same data type as in the Excel document).
  1. Block "Condition" checks the specified condition for truth, after which the execution of the scenario continues towards the "Yes" output (if the condition is met) or towards the "No" output (if the condition is not met).

The condition is written in the format: "variable" equals (==)/ greater than (>)/ less than (<) "value".

For example: $a == "Hello", that is, if the value of the variable $a is equal to "Hello", then the output is "Yes", otherwise the output is "No".

$Result > 5, that is, if the value of the variable $Result is less than 5, then the output is "Yes", otherwise the output is "No".

  1. Block "Close Document" allows closing the Excel document. The following properties are specified for this block:
  • Link to Excel (returns a link to the process of handling the Excel document);
  • Link to document (returns a link to the opened Excel document currently being worked on).
  1. Blocks "Get Cell Value" allow reading a value from a cell in the Excel document. In this case, two "Get Cell Value" blocks are used for different rows and columns. The following properties are specified for this block:
  • Link to document (returns a link to the opened Excel document currently being worked on);
  • Sheet (the ordinal number or name of the sheet where the required cell is located);
  • Row (the row number where the required cell is located);
  • Column (the column number where the required cell is located);
  • Result (returns the content of the cell of the same data type as in the Excel document).
  1. Block "Execute Expression" starts the execution of one or more expressions in a language compatible with PowerShell. In this case, one expression is used.
  1. Block "End" (this block completes the execution of the scenario or returns the subprocess diagram to the main process).

Diagram "Adding Invoice"

After extracting data from the PDF or Excel document, the robot creates an incoming invoice in 1C. This diagram was partially created using the "Record" function of Sherpa Designer. More details about it can be found here.

  1. Block "Start" (any diagram starts from this block).
  2. Block "Log" allows outputting arbitrary messages and/or variable values to the log during the execution of the robot's scenario. For this block, the property "Value" is specified. Here, this block logs a message "Creating nomenclature".
  1. Blocks "Check Element Presence" (checks for the presence of a specified user interface element on the screen), "Click Mouse" (performs a click on the specified application element), and "Press Keys" (emulates key presses on the keyboard) are added to the diagram using the "Record" function. Each of the blocks uses a selector. More details on working with selectors can be found here.
  2. Block "Assign Value to Variable" sets new values for one or more variables. In this case, the properties specify one value that needs to be assigned to a specific variable.
  1. Block "For Each Loop" iterates through all rows of the data table.
  1. Block "Click Mouse" (performs a click on the specified application element) is added to the diagram using the "Record" function.
  2. Block "Pause" pauses the execution of the scenario for a specified time. The following properties are specified for this block:
  • Unit of measurement (the unit of measurement in which the duration of the pause is specified);
  • Duration (the number of seconds for which the scenario execution will be paused);
  • Start immediately (the set flag enables the application of the delay immediately on the first pass of this block from the moment the robot scenario is launched).
  1. Blocks "Click Mouse" (performs a click on the specified application element) and "Press Keys" (emulates key presses on the keyboard) are added to the diagram using the "Record" function. Each of the blocks uses a selector.
  2. Block "Execute Expression" starts the execution of one or more expressions in a language compatible with PowerShell. In this case, one expression is used.
  1. Block "End" (this block completes the execution of the scenario or returns the subprocess diagram to the main process).