Salesforce is a library for accessing Salesforce using REST API. The library extends simple-salesforce library.

More information available at Salesforce REST API Developer Guide.


The keyword execute_dataloader_import can be used to mimic Salesforce Dataloader import behaviour.

input_object can be given in different formats. Below is an example where input is in RPA.Table format in method a and list format in method b.

*** Settings *** Library RPA.Salesforce Library RPA.Database Task Setup Authorize Salesforce *** Tasks *** # Method a ${orders}= Database Query Result As Table ... SELECT * FROM incoming_orders ${status}= Execute Dataloader Insert ... ${orders} ${mapping_dict} Tilaus__c # Method b ${status}= Execute Dataloader Insert ... ${WORKDIR}${/}orders.json ${mapping_dict} Tilaus__c

Example file orders.json

[ { "asiakas": "0015I000002jBLIQA2" }, { "asiakas": "0015I000002jBLDQA2" }, ]

mapping_object describes how the input data fields are mapped into Salesforce object attributes. In the example, the mapping defines that asiakas attribute in the input object is mapped into Tilaaja__c attribute of Tilaus__c custom Salesforce object.

{ "Tilaus__c": { "asiakas": "Tilaaja__c" }, }

Object type could be, for example, Tilaus__c.

Salesforce object operations

Following operations can be used to manage Salesforce objects:

  • Get Salesforce Object By Id
  • Create Salesforce Object
  • Update Salesforce Object
  • Upsert Salesforce Object
  • Delete Salesforce Object
  • Get Salesforce Object Metadata
  • Describe Salesforce Object

There are two ways to set the Salesforce domain. You can set the domain at time of library import or using the Set Domain keyword.

There are several ways to declare a domain at time of library import:

*** Settings *** Library RPA.Salesforce sandbox=${TRUE}

Or using the domain to your Salesforce My domain:

*** Settings *** Library RPA.Salesforce domain="robocorp"

The domain can also be set using the keyword Set Domain:

*** Settings *** Library RPA.Salesforce *** Tasks *** # Sets the domain for a sandbox environment Set Domain sandbox # Sets the domain to a Salseforce My domain Set Domain robocorp # Sets to domain to the default of 'login' Set Domain


Robot Framework

*** Settings *** Library RPA.Salesforce Task Setup Authorize Salesforce *** Variables *** ${ACCOUNT_NOKIA} 0015I000002jBLDQA2 *** Tasks *** Change account details in Salesforce &{account}= Get Salesforce Object By Id Account ${ACCOUNT_NOKIA} &{update_obj}= Create Dictionary Name=Nokia Ltd BillingStreet=Nokia bulevard 1 ${result}= Update Salesforce Object Account ${ACCOUNT_NOKIA} ${update_obj} *** Keywords *** Authorize Salesforce ${secrets}= Get Secret salesforce Auth With Token ... username=${secrets}[USERNAME] ... password=${secrets}[PASSWORD] ... api_token=${secrets}[API_TOKEN]


import pprint from RPA.Salesforce import Salesforce from RPA.Robocorp.Vault import FileSecrets pp = pprint.PrettyPrinter(indent=4) filesecrets = FileSecrets("secrets.json") secrets = filesecrets.get_secret("salesforce") sf = Salesforce() sf.auth_with_token( username=secrets["USERNAME"], password=secrets["PASSWORD"], api_token=secrets["API_TOKEN"], ) nokia_account_id = "0015I000002jBLDQA2" account = sf.get_salesforce_object_by_id("Account", nokia_account_id) pp.pprint(account) billing_information = { "BillingStreet": "Nokia Bulevard 1", "BillingCity": "Espoo", "BillingPostalCode": "01210", "BillingCountry": "Finland", } result = sf.update_salesforce_object("Account", nokia_account_id, billing_information) print(f"Update result: {result}")


Initialize self. See help(type(self)) for accurate signature.