Open Navigation

Salesforce

Salesforce is a cloud based customer relationship management software suite.

Overview

Salesforce provides customer relationship management service software, and has a complementary suite of enterprise applications as well. These are focused on customer service, marketing automation, analytics, and application development. It is the market leader in CRM solutions.


Authentication

When using the Salesforce connector, the first thing you will need to do is go to your Tray.io account page, and select the workflow you wish to work on. Once in the workflow dashboard itself, search and drag the Salesforce connector from the connectors panel (on the left hand side) onto your workflow.

With the new Salesforce connector step highlighted, in the properties panel on the right, click on 'New Authentication' which is located under the 'Settings' heading.

add-auth

You will then need to select the 'scopes' for your authentication to configure exactly what access your Tray workflow will have to Salesforce:

Note that for standard use, you will always need to tick the Api scope.


In the next screen you will then be prompted to enter the credentials of the Salesforce user you will be authenticating with.

This user must be set up correctly in the Salesforce Admin UI, to ensure that you will be able to correctly access all of the available connector operations.

Correct setup of user permissions

The Tray Salesforce connector gives you full access to all of your Salesforce data including leads, contacts, custom objects/fields, and even workflow rules and outbound messages.

Therefore you will need to make sure that the user you authenticate with has access to the correct objects and record types - in a read, write and create capacity, depending on need.

Managing permissions for users in Salesforce can be done using Profiles and Permission Sets.

NOTE: Currently the Salesforce connector can only be used on the Enterprise Edition of Salesforce, and higher. You may use the Salesforce connector on Professional Edition, but ONLY if you've requested API access from your Salesforce account manager. However, you will not be able to use instant WebHooks on the Professional Edition.

Managing access with Profiles

In Salesforce you can allocate a user to a pre-set profile, or you can create your own custom profile.

The available profiles depend on the type of License that a user has.

For example, a Salesforce Platform-licensed user can only have a Standard Platform User profile; while a Salesforce-licensed user (https://help.salesforce.com/articleView?id=users_license_types_available.htm&type=5) can have multiple profiles including Contract Manager and System Administrator which gives comprehensive 'super user' access to all functions and objects.

The Contract Manager profile is more suited to the access level that is required by the Tray Salesforce trigger and connector. This can be seen by looking at the 'Standard Object Permissions' section of the Contract Manager profile settings:

Contract Manager Profile - Standard object permissions

contract-manager-object-permissions

You will note that the Standard Platform User does not have the same set of object permissions - for example it has access to Accounts but no access to Leads, Campaigns or Assets:

Standard Platform User - Standard object permissions

standard-platform-user-object-permissions

So a good approach would be to clone the Contract Manager profile, and then edit the permissions, bearing in mind the following:

In the Standard Object Permissions section you can set basic read and write access to objects such as contracts, leads and accounts.

In the Administrative Permissions section certain basic key permissions can be set - for example API Enabled must be ticked or the authentication will not work.

Several permissions in the General User Permissions section are relevant in that they allow extra functionality that cannot be granted purely through object-level permissions. For example Activate Contracts must be ticked in order for it to be possible to activate a contract, because the Edit permission on Contracts and Orders is not enough to allow contract activation (you can test activating contracts in Tray with the Update Record operation for the Contract record type - setting the Status field to 'Activated').

This applies to several other options in the General User Permissions section, such as Manage Cases and Activate Orders.

The Salesforce admin UI has tooltips which tell you what object settings are also required for certain permissions:

salesforce-tooltip-manage-cases

The following article also provides a useful reference for the object permissions which are required for certain General User Permissions, as well as the required editions:

https://help.salesforce.com/articleView?id=000198725&type=1

For example 'Activate Contracts' links to the following page:

salesforce-activate-contracts

This tells you that you need to select Activate Contracts in General User Permissions and set Read and Edit rights on the contracts object in Standard Object Permissions - as already described above.

Managing access with Permission Sets

In Salesforce it is also possible to use 'Permission Sets' to extend users' functional access without changing their profiles.

So you could create a Permission Set which has all the necessary access and then assign it to a particular user to make the necessary adjustments without affecting the profile they are assigned to.

When you create a Permission Set, you can specify the License that it is available for:

new-permission-set


Salesforce Trigger

If you wish your workflow to be kicked off by a particular action in Salesforce, you can use the Salesforce Trigger.

The Salesforce trigger allows you to receive notifications and trigger workflows when given events occur associated with the selected trigger operation.

The Salesforce trigger is somewhat unique in that not only can you White-labelling the trigger (adjust objects with prefixes), but it also has two types of trigger events available:

  • Handling Events from the Salesforce Trigger (See immediately below) Followed by:
    • Standard trigger events
    • Manually-created trigger events

Important note on Handling Events from the Salesforce Trigger

From version 2.7 and above the Salesforce Trigger receives trigger events as an 'events' array, instead of an object which can be directly queried.

So any attempts to directly query an object with a jsonpath such as $.steps.trigger.Id will fail.

If you are creating a new Salesforce trigger, or updating your trigger from version 2.6 or earlier, you will need to set up a loop to go through the events array and take whatever action is needed for each item in the loop. Sometimes the trigger will return multiple events, but it can also return single events (which will then only trigger a single run of the loop).

The Loop Events step will need to set $.steps.trigger.events as the list to loop through. Then, as an example, a Get account Salesforce step could retrieve the account by pulling the id with $.steps.loop-1.value.Id:

salesforce-loop-trigger

White-labelling the trigger

The default behaviour of the trigger is to prefix the newly created objects with the string Tray.

tray_prefix

From connector version 2.8 onwards, this prefix can be customised using the Object prefix field found in advanced settings.

new_prefix

The string provided will then be used as the prefix for objects created in Salesforce.

new_prefix_salesforce

Standard trigger events

This type of trigger event is where Tray.io creates a number of Salesforce Objects which results in Salesforce sending notifications when a certain event occurs. These objects are the following:

  1. RemoteSiteSetting: Before any notification can be sent the target URL has to be registered as a RemoteSiteSetting.

  2. Workflow rule: A WorkflowRule is created to tell Salesforce when it should send an Outbound message to the workflow.

  3. Outbound message: An OutboundMessage is created and it defines what data is sent to the workflow.

The operations that fall under this category are:

Standard trigger operations available:

  • On custom workflow formula
  • On create
  • On create/update
  • On field change
  • On multiple field changes
  • On update

Full list of Salesforce operations can be found HERE

Manually-created trigger events

This type of trigger event is where you have to login into Salesforce and create/configure a number of Salesforce Objects which results in Salesforce sending notifications to your workflow.

The trigger events that fall under this category are:

Manually-created trigger operations:

  • On Apex Trigger
  • On Outbound Message

Full list of Salesforce operations can be found HERE

Webhook Setup

The Salesforce Trigger uses the same authentication method which is described in the first section of this page.

Note that when using the Salesforce trigger, you currently must use a permission set and add it to the User that you will be authenticating with. This permission set must have the 'Modify all Data' permission.

For more details on this operation please see our demo below called Trigger: Outbound message.


Note on Operations usage

Salesforce has a few operations that - due to the inherent nature of the API itself -IMPORTANT: Please note that for warrant further explanation:

IMPORTANT: Batch operations (see immediately below)
Followed by: * Handling Leads * Bulk operations * SOQL Query & SOSL Query

Important note on Batch Operations

BATCH UPDATE

It is important to take certain steps to handle errors with the Batch Update operation which may pass undetected.

This is because, even though some error statuses might be returned by the Salesforce API, the fact that a response has been returned at all is treated as a successful execution by the Tray.io Salesforce connector.

For example a status of 404: NOT FOUND might be returned and, as you can see, in the debug output it has still returned green:

salesforce-404-error

So you will need to set up a system for dealing with these errors. A very rudimentary approach would be a workflow which takes the following steps:

  1. Uses a boolean to check if the above output log returns hasErrors: true
  2. Sends a timestamp of the batch run to Slack
  3. Loops through the results from the Salesforce output
  4. Extracts all those whose status was not 204
  5. Sends a message to a batch errors channel in Slack for each errored account/lead etc.

salesforce-batch-error-workflow

The end result would be notifications such as:

salesforce-batch-error-slack-output

Another approach might be to use a script like the following which would dig back into the original update list you had compiled to replicate the info that was sent to Salesforce:

salesforce-batch-error-script

And produce a result such as:

salesforce-batch-error-slack-output

Please Note: Each object in the Batch Update array contains additional metadata, with field values nested inside a fields attribute.

// You can reference the input variables using input.NAME
exports.step = function(input) {
return _.map(input.rows, function(row) {
return {
"object_id": row.contact_id,
"fields": [
{
"key": "Role__c",
"value": row.role
}
]
}
});
};

BATCH CREATE

IMPORTANT: Unlike the Batch Update array, every element in the Batch Create array needs to be just an array of field name-value objects.
// You can reference the input variables using input.NAME
exports.step = function(input) {
return _.map(input.rows, function(row) {
return [
{
"key": "Role__c",
"value": row.role
},
{
"key": "AccountId",
"value": row.account_id
},
{
"key": "FirstName",
"value": row.first_name
},
{
"key": "LastName",
"value": row.last_name
},
{
"key": "Email",
"value": row.email
}
];
});
};

Handling Leads in Salesforce

Tray.io lets you handle Leads in Salesforce with ease. Using the Salesforce connector, you can find a list of records from Salesforce, using the "Find Records" operation.

IMPORTANT!: Please note that LEADS CAN BE CONVERTED
.

Once a lead is converted, you cannot update them in any way, and they are no longer available in the Salesforce interface.

Behind the scenes in the API, Salesforce uses a "Converted" field which is either true or false. You can use this in the Salesforce connector to get a list of leads who haven't been converted yet, for example.

Going a step further, leads can be converted into Contacts, Opportunities, and Accounts. In tray it's possible to get the "ID" of the relevant new converted objects using the "Converted Account ID", "Converted Opportunity ID" and "Converted Contact ID" fields.

Bulk operations

The Salesforce connector uses the Bulk API, which follows a slightly different process when manipulating records. When using any operation with the word Bulk in the name, this means that the Bulk API is being used. When a bulk operation is used, Salesforce does not process the data immediately, instead it starts a Bulk Data Load job. The time in which it takes for this job to finish depends on resources available in your Salesforce instance.

The asynchronous nature of bulk data loading in Salesforce means that in the workflow, you would use a bulk data operation and then you would receive a Job ID (or just ID as shown in the connector step output).

This job ID can then be used to poll for the status of the job. Only when the job shows a status of JobComplete has the data been successfully processed in Salesforce.

For more details on this operation please reference the demo below called Operation: Leads - 'Bulk Upsert'.

SOQL Query & SOSL Query operations

The Salesforce Object Query Language (SOQL) and Salesforce Object Search Language (SOSL) APIs can be used to search your organisation’s Salesforce data.

Generally speaking when using these query operations, you should use SOQL to query one operation at a time, and SOSL when you want to search text, email, phone fields, etc (basically when searching multiple objects simultaneously). This is why the latter is better to use when querying a relationship between objects and such.

Here are some points you need to consider when choosing between the two query operations:

Use SOQL when you know which objects the data resides in, and you want to:
  • Retrieve data from a single object or from multiple objects that are related to one another.
  • Count the number of records that meet specified criteria.
  • Sort results as part of the query.
  • Retrieve data from number, date, or checkbox fields.
IMPORTANT: Please note that for for SOQL Query to accept your date references, the format MUST BE: YYYY-MM-DD. Please see the SOQL API Documentation for more details.
Use SOSL when you don’t know which object or field the data resides in, and you want to:
  • Retrieve data for a specific term that you know exists within a field. Because SOSL can tokenize multiple terms within a field and build a search index from this, SOSL searches are faster and can return more relevant results.
  • Retrieve multiple objects and fields efficiently where the objects might or might not be related to one another.
  • Retrieve data for a particular division in an organization using the divisions feature.
  • Retrieve data that’s in Chinese, Japanese, Korean, or Thai. Morphological tokenization for CJKT terms helps ensure accurate results.

The language used is crucial for your search patterns. In principal, it is extremely similar to SQL in text style.

With the above taken into consideration, below is an example of a SOQL query, which also involves using the Date & Time helper connector (notice how the 'Format' has been deliberately set up to suit Salesforce protocols):

salesforce-soql-date-time

This image demonstrates the way one may use the SOSL query operation to run through 'All Fields' available, in order to return any and all account names and IDs found (unlike the above query example, this is tailored towards multiple )

salesforce-sosl-example

For further information regarding the Salesforce Object Query Language (SOQL) and Salesforce Object Search Language please see their API Documentation site for more details.


## Example usage

TRAY POTENTIAL: Tray.io is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with Tray.io and this connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Below are a few examples of ways in which you could potentially use the Salesforce connector, depending on your use case and level of skill. Please choose the one most relevant to you and enjoy the demo.


Sample use case

Below is an example of a way in which you could potentially use the Salesforce trigger AND connector, to integrate with Trello. In this imagined scenario, upon creation of a Salesforce record, the workflow checks who created said card and if it was a Partner referral. Should this be the case, the Tray.io workflow will set a time limit for contact to be made.

The steps will be as follows:

  1. Setup the trigger and the first connector step in order to get the new record information.
  2. Create a boolean condition to base your output on.
  3. If a partner referral is not confirmed, create a Trello card as standard.
  4. If a partner referral is confirmed, set a contact due date on said Trello card.

The final outcome should look like this:

salesforce-example-1-complete-wf

1 - Setup trigger & Get record info

Once you have clicked 'Create new workflow' on your main Tray.io dashboard (and named said new workflow), select the 'Salesforce Trigger' from the trigger options available:

salesforce-trigger-select

Once you have been redirected to the Tray.io workflow dashboard, choose your Salesforce authentication, and set the operation to 'On Record Create'. You will see the option to select 'Record type' is mandatory. Choose from the dropdown options available: 'Lead'.

salesforce-trigger-lead

Note: If you click on 'Show advanced properties' you will see the 'Object prefix' option mentioned earlier in the Trigger -> demo app section of this documentation page.

Next, add the first Salesforce connector step. Search and drag over the connector from the left hand panel, into your workflow. Set the operation to 'Find records' and 'Record type' to 'Lead'.

While this step will seem similar to the first one, its purpose is different. The trigger is activated upon a new Lead record being created. The connector step finds said record to get the record info.

salesforce-find-records-lead

Below this section is an input field that is mandatory - 'Conditions matching'. As this is pre-filled to 'Match all conditions' you need not worry about it for this example.

2 - Set the conditions

Add another connector step to your workflow, this time utilising the Boolean core connector.

It is here that the conditions are set regarding the two alternative outputs we intend to make.

The first value is generated using jsonpaths and the connector-snake.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray.io, please see our Intro page and Data Guide for more details

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

The first input will be: $.steps.salesforce-1.records[0].LeadSource. This means that the the LeadSource found in the step previous will be what is tested.

The 'Comparison type' is set to: Equal to which is self explanatory. The final section is what the LeadSource is queried against: Partner Referral.

NOTE: Please make sure to double check your input selectors are set accurately! The first condition is set as a jsonpath, while the next two are strings. If this is not correct then your workflow will come back with an error.

salesforce-boolean

3 - False branch

On the left hand branch of the boolean condition, aka the 'FALSE' branch, drop and drag a Trello connector.

Add your Trello authentication as appropriate, and set the operation to 'Create new card'.

If you dont have your Trello authentication set up, please see our Trello docs for more details

Your 'Board ID' will be available from a list of dropdown options, as will your 'List ID'. The 'Name' field we can generate via utilising the connector-snake once more and linking it to "Salesfroce step 1" again as it has all the information regarding said record (including its name).

In the description field our demo is using Tray.io's own interpolation method to auto-generate the output so that it can be displayed easily.

INTERPOLATION: When you wish to include JSON generated data within another input/ output/ result, use our Interpolation method as described here.

Your connector should look similar to this be the end of setup:

salesforce-boolean-false

Notice that the 'Due Date' is left blank here, as we have not set it (check the bottom right hand corner of the above image). While this is not a mandatory field, it will be important on the 'TRUE' branch later.

4 - True branch

On the right hand branch of the boolean condition, aka the 'TRUE' branch, drop and drag a Date & Time Helper connector.

This connector will be used to get the current time stamp for the workflow being processed. Set the operation to do just that by selecting 'Get current timestamp'. choose your timezone, and your preferred format as well.

salesforce-boolean-true-1

Take a second Date & Time Helper connector and place it below the first one. In this case the operation will be creating a set time: 'Add to date'. The only other field we need fill in is the 'business days' option, which in this demo will be 1 day.

salesforce-boolean-true-2

Finally add a Trello step and fill it in as described previously. This time you may wish to highlight the fact that this was a partner referral within the card description.

Using the connector-snake once more, fill in the due date the time helpers step 2 result: $.steps.date-time-helpers-2.result

Your final step should be filled out as follows - you will notice that we have also included the due date in the description step as well:

salesforce-boolean-true-3

Once you run your workflow, depending on your outcome you will now auto-generate Trello cards, both will have descriptions attached as per our interpolation within the descriptions we made earlier.

Below is an example of one card that is in viewing mode, which has a partner referral and therefore also includes a due date:

salesforce-trello-cards-duedate

Congratulations! your Salesforce workflow is now complete.


Trigger Demo: Custom workflow

Below is an example of a way in which you could potentially use the Salesforce trigger using the 'On custom workflow' operation. Due to the complexity, we have very briefly outlined the method and included links to the Salesforce documentation where necessary for further guidance.

The steps will be as follows:

  1. Select and set up the Salesforce trigger.
  2. Create a Salesforce workflow formula.

The final outcome should look like this:

salesforce-complete-wf-trigger-1

1 - Setup trigger

Once you have clicked 'Create new workflow' on your main Tray.io dashboard (and named said new workflow), select the Salesforce trigger from the trigger options available:

salesforce-trigger-select

Once you have done this, make sure to either choose a previous Salesforce authentication or create a new one as appropriate.

Set the operation to 'On custom workflow formula':

salesforce-trigger-recordtype

Please note that the 'Record type' field is mandatory, and that for this example we have set it to 'Contact'.

2 - Create Salesforce workflow formula

The second mandatory field is 'Formula'.

This is to let Salesforce know when they need to send a notification to your workflow.

The formula in the example below tells Salesforce to send a notification when a new account is created or when the field 'Name' is updated in an account: ISNEW()||ISCHANGED(Name)

salesforce-trigger-formula

For more information about how to create your own formulas, check out the following Salesforce documentation links:


Trigger Demo: Outbound message

Below is an example of a way in which you could potentially use the Salesforce trigger, with the 'On Outbound message event' operation.

Due to the complexity of the Salesforce UI, we have outlined the navigation as clearly as possible for the sake of our users.

The steps will be as follows:

  1. Select and set up the Salesforce trigger.
  2. Get your Tray.io public URL.
  3. Update your 'Remote site settings' within Salesforce.
  4. Create and set up your new Workflow Rule

The final outcome should look like this:

salesforce-complete-wf-trigger-2

1 - Setup trigger

Once you have clicked 'Create new workflow' on your main Tray.io dashboard (and named said new workflow), select the Salesforce trigger from the trigger options available:

salesforce-trigger-select

Once you have done this, make sure to either choose a previous Salesforce authentication or create a new one as appropriate.

Set the operation to 'On outbound message':

salesforce-trigger-setup-2

Please note that the 'Record type' field is mandatory, and that for this example we have set it to 'Account'.

2 - Get the Public URL

The first thing you will need is your Tray.io public URL. This can be found in the settings of your workflow dashboard.

Go to the top left hand setting cog.

salesforce-example-settings

Once you click through, you will be redirected to the main workflow settings page. Your 'Workflow Public URL' will be displayed clearly. Copy this URL, and save it for now for use later.

salesforce-example-public-url

3 - Updating 'Remote site settings' in Salesforce

First login into your Salesforce account.

Click on the setting cog in the top right hand corner, near your profile picture. In the dropdown options displayed, select 'Setup'.

salesforce-setup

This will direct you to the Salesforce main Setup page. In the search bar at the top, query the term: Remote Site Settings

salesforce-search

This can also be found by going to the the Setup right hand navigation menu, selecting Settings -> Security -> Remote Site Settings.

You will be redirected to a new tab, that should list all your remote sites available. In the centre of this table at the top, you will see a 'New Remote Site' button.

salesforce-remote-site-new

Click on the 'New Remote Site' button, and configure the new remote site settings where the field: 'Remote site URL' is the value of the workflow public URL, that you copied earlier from the Tray.io dashboard settings.

salesforce-remote-site-setup

When finished hit save.

4 - Create your Workflow Rule

Go once more the the Salesforce search bar and type in Workflow Rules. You will be redirected to a new Salesforce section which should have the title of "ALl Workflow Rules". In the middle of the layout, there is a button much like before, which gives you the option to create a new value (in this case, 'New Rule').

salesforce-new-rule

Click on this button to be redirected once more, this time to the 'New Rule' setup page. This is where we need to configure the new workflow rule. This rule, is what will be used to tell Salesforce under what specific circumstances, you want your Salesforce Tray.io workflow to be be triggered (or rather, send your workflow a notification).

In this case, the workflow rule will apply to the 'Account' object. Select this from the dropdown options available.

The workflow itself will be triggered only when a an account whose name starts with the letter R is created.

Fill in the evaluation and rule criteria as shown using the dropdown options etc:

salesforce-new-rule-setup

When you click through to the next page, you will need to say what happens when the event (that was just defined) has occurred. In this case, we want to create a new outbound message:

salesforce-new-rule-outbound

As soon as you select 'New Outbound Message' you will be redirected to another screen. This is where you will dictate WHERE and WHAT information you will be sending.

In the Endpoint URL field, make sure to once more add the Tray.io public URL that you took note of earlier.

You can also then say what information you want sent in the workflow notification. The example below is sending the new Accounts Id and Account Name.

salesforce-new-rule-fields

Once you have set this up and clicked through you will come to the final page which is in fact the "Workflow Rules" configuration page from earlier. Press the 'Done' button to complete setup.

salesforce-new-rule-done

All that is left is you for to activate your Tray.io workflow and wait for an account name (with the starting letter of "R") to be created and your workflow will run.


Bulk Upsert Demo

Below is an example of a way in which you could potentially use the Salesforce connector, to Bulk upsert records to your salesforce instance.

The steps will be as follows:

  1. Setup the Form trigger and Upload a CSV file using.
  2. Start the background bulk data job in Salesforce via utilising the Bulk Upsert operation.
  3. Poll Salesforce for Job completion status of said bulk upload.
  4. Create a check and delay for job status depending on results.
  5. Exit loop when the upload is complete and get Job completion records

The final outcome should look like this:

salesforce-example-2-complete-wf

1 - Setup Form trigger

In order to use the 'Bulk upsert records' operation, it requires that a file object be generated by a previous connector step (such as the Google Drive connector, CSV Editor or the in our use case, the Form trigger). This creates a file object like so:

salesforce-file-object

With this understanding, click on the 'Create new workflow' button on your main Tray.io dashboard, name said new workflow, and select the 'Form Trigger' from the trigger options available:

salesforce-form-trigger

Once you have been redirected to the Tray.io workflow dashboard, set the operation to "Form request". This means that when a customizable form is submitted, the workflow will trigger.

In the following field options displayed, setup accordingly starting with 'Form Title'. In 'Input Fields' -> 'Field', choose 'File upload'.

The 'Name' of the field is what it will be called, when you refer to it in the jsonpaths. The 'Label' is what you will see on the form page where you upload said file. Choose accordingly from your dropdown options,

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray.io, please see our Intro page and Data Guide for more details.

Notice that in the example given, we have used customizable fields, which are non-standard. Account, Lead, etc are all perfectly fine to use should you wish to do so.

In this case, we trigger the form by uploading manually uploading a CSV file that contains other files. You can do this by going to the public URL page of your workflow. This can be found in the Settings cog in the top left hand corner. You should see a popup box similar to the below:

salesforce-public-url

Once you click on the url link, this should in turn take you to the online form page, where you can upload your dummy data:

salesforce-form-upload

Feel free to add descriptions and update your step titles to make it easier to understand your step by step process.

2 - Salesforce Bulk upsert records

Drag your first Salesforce connector step into your workflow and set the operation to 'Bulk upsert records'.

Select your 'Record type' and 'External field name' to what is available from your dropdown lists.

When the data is processed, it is the 'External field name' field, that existing records will be referenced by and updated. If Salesforce can't find a record with the same value in this field, it will create a new record. Therefore field must exist in your CSV file.

Your 'CSV file' field can be generated using the connector-snake and should output: $.steps.trigger.result.file_object[0].

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

Additional options are also available for the formatting of the CSV file being uploaded. For example, the default delimiter is a comma but other characters can be chosen. Typically if a CSV file is generated using a Windows application then the Line end would most likely be CRLF, otherwise LF should work.

salesforce-bulk-upsert-step

Once run, you should be able to see the Name and Label fields from the previous step, in the Debug panels input. Notice that due to the custom names created, the format that comes through the Salesforce API is slightly more complicated than what the "user" would normally see:

salesforce-bulk-upsert-output

3 - Polling Salesforce

Add a Loop connector to your workflow and set the operation to 'Loop Forever'.

Drag another Salesforce step to your workflow and set the operation to 'Get job info'. Using the connector step once more, have your 'Job ID' generated via the connector-snake so that you get a perfect jsonpath from your original Salesforce step.

salesforce-polling-check

The second Salesforce step, is designed to check on the job status - i.e. if the bulk upload has been completed, if this is not the case (which we will check for later on in the workflow), the loop re-runs the process.

On each iteration of the Loop, we check if the job has succeeded by looking at the status field. If job has completed it will show a status of JobComplete.

4 - Check Job status

Add a Boolean connector step and set the operation to 'Boolean condition'. Set your first condition to: $.steps.salesforce-2.state and make sure the 'Comparision type' is 'Equal to'. The second value needs to be set to JobComplete. As explained previously, this is what the workflow will look for in order to break the polling loop.

salesforce-boolean-check

Add a Break Loop connector to the TRUE branch of the workflow. The operation will be 'Break' and the loop it will be referring to is 'loop-1'.

One the FALSE branch add a Delay connector, and set the operation to 'Delay' as well. The time unit here will be in minutes, and we will set this as '1' in the delay amount field.

IMPORTANT: Please be aware that this demo makes multiple API calls...As many users have a limited allocated number of API calls that they can make to Salesforce, in order to reduce the number of calls made, simply increase the delay time. We would also advise that the `JobComplete` is possibly updated to `UploadComplete` instead.

salesforce-boolean-delay

5 - Get Job Information

Add a final Salesforce connector step to your workflow. This is used to gather the job information (how many files uploads, which failed, time taken etc). Set the operation to 'Get job info' and the 'Job ID' to: $.steps.salesforce-1.id.

In your Debug panel you should see results similar to below:

salesforce-job-info

Congratulations! You have completed your Salesforce Bulk Upsert Demo.

Was this article helpful?
Yes
No