Authorize to Salesforce with security token, username,
password, connected app key, and connected app secret
creating instance.
Argument | Type | Default value |
---|
username | str | null |
password | str | null |
api_token | str | null |
consumer_key | str | null |
consumer_secret | str | null |
embed_api_token | bool | False |
param username: | Salesforce API username |
---|
param password: | Salesforce API password |
---|
param api_token: | Salesforce API security token |
---|
param consumer_key: | Salesforce connected app client ID |
---|
param consumer_secret: | Salesforce connected app client secret |
---|
param embed_api_token: | Embed API token to password (default: False) |
---|
Python
from RPA.Salesforce import Salesforce
from RPA.Robocorp.Vault import Vault
SF = Salesforce(domain="robocorp-testing-stuff.develop.my")
VAULT = Vault()
secrets = VAULT.get_secret("salesforce")
SF.auth_with_connected_app(
username=secrets["USERNAME"],
password=secrets["PASSWORD"],
api_token=secrets["API_TOKEN"],
consumer_key=secrets["CONSUMER_KEY"],
consumer_secret=secrets["CONSUMER_SECRET"],
)
Robot Framework
*** Settings ***
Library RPA.Salesforce domain=robocop-testing-stuff.develop.my
Library RPA.Robocorp.Vault
*** Tasks ***
Authenticate to Salesforce using connected app
${secrets}= Get Secret salesforce
Auth with connected app
... username=${secrets}[USERNAME]
... password=${secrets}[PASSWORD]
... api_token=${secrets}[API_TOKEN]
... consumer_key=${secrets}[CONSUMER_KEY]
... consumer_secret=${secrets}[CONSUMER_SECRET]
Execute APEX operation.
Argument | Type | Default value |
---|
apex | str | null |
apex_data | Dict, None | None |
apex_method | str | POST |
kwargs | | null |
The APEX classes can be added via Salesforce Developer console
(from menu: File > New > Apex Class).
Permissions for the APEX classes can be set via Salesforce Setup
(Apex Classes -> Security).
param apex: | endpoint of the APEX operation |
---|
param apex_data: | data to be sent to the APEX operation |
---|
param apex_method: | operation method |
---|
param kwargs: | additional arguments to be passed to the APEX request |
---|
return: | result of the APEX operation |
---|
Python
from RPA.Salesforce import Salesforce
SF = Salesforce(domain="robocorp-testing-stuff.develop.my")
# authenticate to Salesforce
SF.execute_apex(apex="MyClass", apex_data={"data": "value"})
result = SF.execute_apex(
apex="getAccount/?id=0017R00002xmXB1QAM",
apex_method="GET")
Robot Framework
*** Settings ***
Library RPA.Salesforce domain=robocop-testing-stuff.develop.my
*** Tasks ***
Executing APEX operations
# Authenticate to Salesforce
&{apex_data}= Create Dictionary data=value
${result}= Execute APEX MyClass apex_data=${apex_data}
${result}= Execute APEX
... apex=getAccount/?id=0017R00002xmXB1QAM
... apex_method=GET
Keyword mimics Salesforce Dataloader 'insert' behaviour by taking
in a input_object`representing dictionary of data to input into Salesforce,
a `mapping_object representing dictionary mapping the input keys into
Salesforce keys, an object_type representing Salesforce object which
Datahandler will handle with operation type.
Argument | Type | Default value |
---|
input_object | Any | null |
mapping_object | Any | null |
object_type | str | null |
Stores operation successes into Salesforce.dataloader_success array.
Stores operation errors into Salesforce.dataloader_errors.
These can be retrieved with keywords get_dataloader_success_table and
get_dataloader_error_table which return corresponding data as
RPA.Table.
param input_object: | filepath or list of dictionaries |
---|
param mapping_object: | filepath or dictionary |
---|
param object_type: | Salesforce object type |
---|
return: | True if operation is successful |
---|
Used to determine the current domain that has been set
returns: | string of the currently set domain |
---|
Used to set the domain the Auth With Token keyword will use. To set
the domain to 'test' or if using a sandbox environment use "sandbox" as the
domain. If you have a Salsesforce My domain you may also input that name. If
the domain argument is not used the default domain is "login".
Argument | Type | Default value |
---|
domain | str | login |
param domain: | "sandbox" or the name of the Salesforce My domain;
if no argument provided defaults to "login" |
---|