Skip to content

Instantly share code, notes, and snippets.

@weiserman
Last active February 1, 2022 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weiserman/85e67532ded325ba3e08d5813bb67030 to your computer and use it in GitHub Desktop.
Save weiserman/85e67532ded325ba3e08d5813bb67030 to your computer and use it in GitHub Desktop.
Upload file to process in robocorp
*** Settings ***
Documentation This robot will be run in robocloud, ask user for input file and then load work items
Library Collections
Library RPA.Tables
Library RPA.Dialogs
Library RPA.Robocorp.Process
Library RPA.Robocorp.Vault
*** Variables ***
${CSV_FILE} devdata${/}price_increase.csv
@{ITEMS}
*** Tasks ***
Split Quote File
Request CSV File
Start process with work items
*** Keywords ***
Initialize Process Library
${secrets}= Get Secret ProcessAPI
Log ${secrets}[apikey]
Set Credentials
... ${secrets}[workspace_id]
... ${secrets}[process_id]
... ${secrets}[apikey]
*** Keywords ***
Start process with work items
[Documentation] Columns in CSV ['customer_ID', 'client_Name', 'customer_Name', 'contract_Name', 'Service_Type', 'Quote_code', 'Price increase', 'old total', 'new total', 'test mode']
Initialize Process Library
${table}= Read table from CSV path=${CSV_FILE} dialect=excel header=True
${rows} ${columns}= Get table dimensions ${table}
Log Table has ${rows} rows and ${columns} columns. Columns are: ${table.columns}
${table}= Read table from CSV path=${CSV_FILE} dialect=excel header=True
${rows} ${columns}= Get table dimensions ${table}
Log Table has ${rows} rows and ${columns} columns. Columns are: ${table.columns}
${file}= Create List
... ${CSV_FILE}
${item_id}= Create Input Work Item
... files=${file}
Start Configured Process
... config_type=work_items
... extra_info=${item_id}
*** Keywords ***
Request CSV File
[Documentation] Prompt for input file
Add heading
... heading=Price change robot
... size=Large
Add text ${\n} ${\n}
Add file input
... label=Please select CSV file
... name=fileupload
... file_type=CSV files (*.csv)
... destination=${CURDIR}${/}output
Add text ${\n} ${\n}
Add checkbox
... name=testflag
... label=Test Run?
... default=True
Add text ${\n} ${\n}
Add checkbox
... name=silentmode
... label=Run in background (don't show browser)?
... default=False
Add submit buttons
... buttons=Cancel,Submit
... default=Submit
${response}= Run dialog width=900 title=Please provide input file for processing
# If cancel is pressed end robot run
IF $response.submit == "Cancel"
Log Cancel processing requested by user #Stop processing! #TODO
END
Set Global Variable ${TEST_FLAG} ${response.testflag}
Set Global Variable ${SILENT_MODE} ${response.silentmode}
Set Global Variable ${CSV_FILE} ${response.fileupload}[0]
Log Test mode is: ${TEST_FLAG}
Log File is: ${CSV_FILE}
[Teardown] Close all dialogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment