Copy Rows

Copies the values of one or more specific rows from one table to another.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

copyRows --target(DataTable) [--orderby(String)] [--indexes(List<Numeric>)] [--where(String)] --dataTable(DataTable) (Boolean)=success (Numeric)=changedrowscount

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Target target Required Data Table Data table that should receive the copy of the rows from the source data table.
Order by orderby Optional Text Enter the type of sorting that is used.

Enter the name of the column followed by the sorting method "ASC" or "DESC".

You can enter more than one sort for different columns of the table, as follows: Company ASC, City DESC.
Indexes indexes Optional List<Number>, List<Text>, Number Position of the row to copy.
Where where Optional Text Text responsible for finding a certain value in a table cell.

You can use the text which primitive data, such as Numeric, or a collection of the Numeric or String types.

Use the syntax based on the LINQ C#external link language standards.
Source dataTable Required Data Table Source data table, with the rows that should be copied.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Success success Boolean Returns True if the row was successfully copied, otherwise returns False.
Copied rows changedrowscount Number Number of rows that were copied.


Use the Copy Rows command to copy the first row of a data table to another. Then, open the Excel file to see the copied row.

defVar --name excelFile --type Excel
defVar --name tableExcel --type DataTable
defVar --name emptyExcelFile --type Excel
defVar --name emptyExcelTable --type DataTable
defVar --name numberCopyLines --type Numeric
defVar --name resultCopy --type Boolean
// Enter a filled data table in the file parameter.
excelOpen --file tableFiled excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  tableExcel=value
// Table without values, only with header.
// Enter an empty data table in the file parameter.
excelOpen --file "tableEmpty.xlsx" emptyExcelFile=value
excelGetTable --file ${emptyExcelFile} --getfirstsheet  --entiretable  --hasheaders  emptyExcelTable=value
copyRows --target ${emptyExcelTable} --indexes 1 --dataTable ${tableExcel} desc" numberCopyLines=changedrowscount resultCopy=success
logMessage --message "Success: ${resultCopy}\r\nCopied Lines: ${numberCopyLines}" --type "Info"
excelClose --file ${excelFile}
excelClose --file ${emptyExcelFile} --save
// The above example returns the following output:
// Success: True
// Rows Copied: 1


You must enter a value to either the indexes or where parameters. However, you must not use both at the same time.