# Quickstart

> The purpose of this guide is to help you create a working sample to quickly verify the connection to your Salesforce Org and get familiar with the included activities input/output datatypes.

## Overview

The purpose of this guide is to help you create a working sample to quickly verify the connection to your Salesforce Org and get familiar with the included activities input/output datatypes.

After completing the steps in this guide, you'll have an automation sequence that does the following:

1. Creates `SecureString` variables for your Salesforce credentials and [Invoke Method](https://docs.microsoft.com/en-us/dotnet/api/system.activities.statements.invokemethod?redirectedfrom=MSDN&view=netframework-4.8).
2. Establishes a connection to your Salesforce Org using your `SecureString` credentials ([Salesforce Application Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/salesforce-application-scope))
3. Creates a new Salesforce account record ([Insert Record](https://docs.uipath.com/activities/other/latest/legacy-integrations/insert-record)).
4. Uploads a file to your Salesforce Org ([Upload File](https://docs.uipath.com/activities/other/latest/legacy-integrations/upload-file)).
5. Assigns the uploaded file to your new Salesforce account record ([Assign File](https://docs.uipath.com/activities/other/latest/legacy-integrations/assign-file)).
6. Verifies the results of the **Insert Record**, **Upload File**, and **Assign File** activities by outputting each of their [SalesforceStatus objects](https://docs.uipath.com/activities/other/latest/legacy-integrations/about-the-salesforce-activities-pack) ().

## Prerequisites

Before you begin:

1. Complete the Salesforce [Setup](https://docs.uipath.com/activities/other/latest/legacy-integrations/uipath-salesforce-sfdc-setup) steps.
2. Create a new automation project.
   1. Open UiPath Studio.
   2. Under **New Project**, click **Process** (this opens a **New Blank Process** window).
   3. Enter a project **Name**, **Location**, and **Description**.
   4. Click **Create**.

      ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183541-4af4629e-a1a52e51.webp)
3. Install the **UiPath.Salesforce.Activities** package.
   1. In the **Design** ribbon, click **Manage Packages** (this opens the **Manage Packages** window).
   2. Under **All Packages**, click **Official**.
   3. In the **Search** bar, enter *Salesforce*.
   4. Click, install and accept the license for the **UiPath.Salesforce.Activities**.
      * For more information about Uipath Studio packages, see [Managing Packages](https://docs.uipath.com/studio/docs/managing-activities-packages) in the Studio Guide.

        ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-187742-c4e4a022-5cbed463.webp)

## Steps

### Build your project

The **Salesforce Application Scope** activity requires `SecureString` datatypes for the **Consumer Secret**, **Password**, and **SecurityToken** input properties. To get these `SecureString` datatypes, you convert the `String` values you stored for these properties when completing the [Get your credentials](https://docs.uipath.com/activities/other/latest/legacy-integrations/uipath-salesforce-sfdc-setup) steps in the **Setup** guide.

:::note
The steps below are intended to demonstrate how you can convert a `String` to a `SecureString`. For simplicity and to help you quickly create working sample, the conversion is done within your project sequence and requires you to enter your credential values as variables. This is not recommended when creating shareable or non-example projects. When creating shareable or non-example projects, you can create and reference external workflows that get your **Consumer Secret**, **Password**, and **SecurityToken** from a local source (e.g., .txt, .xlsx files) and perform the conversion using <in> and <out> arguments.
:::

#### Convert Strings to SecureStrings
1. Create the following three variables:
   1. `String` with your Salesforce login password as the **Default** value (e.g., **Name**: *textPassword*, **Default**: *"UiPath123*")
   2. `SecureString` with *New SecureString()* as the **Default** value (e.g., **Name**: *securePassword*, **Default**:*New SecureString()*)
   3. `SecureString` (e.g., **Name**: *password*)
      * For all `SecureString` variables, select the *System.Security.SecurityString* type.
   4. Add a new statement to the process.
   * Recommendation: change the **Display Name** to *"Create SecureString - Password"* or something to make it easy to identify its purpose.
2. Add a activity inside the **Sequence**.
   1. In the **TypeArgument** property, select *System.Char*.
   2. In the **Values** property, enter the `String` variable (e.g., *textPassword*).
3. In the **For Each** activity, add the [InvokeMethod](https://docs.microsoft.com/en-us/dotnet/api/system.activities.statements.invokemethod?redirectedfrom=MSDN&view=netframework-4.8) activity (Programming > Execute > InvokeMethod).
   1. In the **TargetObject** property, enter your first `SecureString` variable (e.g., *securePassword*)
      * Make sure the the **TargetType** property is *(null)* (either the **TargetObject** or **TargetType** is allowed, not both).
   2. In the **MethodName** property, enter *AppendChar*.
      * The [AppendChar](https://docs.microsoft.com/en-us/dotnet/api/system.security.securestring.appendchar?view=netframework-4.8#%20System_Security_SecureString_AppendChar_System_Char_) method is used to add a UTF-16 code unit after the string.
   3. In the **Parameters** property, add a new parameter using the following values: **Direction**: *In*, **Type**: *System.Char*, **Value**: *item*.
4. Add the activity after the **InvokeMethod** activity.
   1. In the **To** property, enter your second `SecureString` variable (e.g., *password*).
   2. In the **Value** property, enter your first `SecureString` variable (e.g., _securePassword).

      ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-180820-a084f7ae-dd5225f2.webp)
5. Create the following three variables:
   1. `String` with your Consumer Secret as the **Default** value (e.g., **Name**: *textPassword*, **Default**: *"4FA94..."*)
   2. `SecureString` with *New SecureString()* as the **Default** value (e.g., **Name**: *secureConsumerSeret*, **Default**:*New SecureString()*)
   3. `SecureString` (e.g., **Name**: *consumerSecret*)
      * For all `SecureString` variables, select the *System.Security.SecurityString* type.
   4. Repeat steps 2-5 to convert your **Consumer Secret** `String` to a `SecureString`.
6. Create the following, 3 variables:
   1. `String` with your Security Token as the **Default** value (e.g., **Name**: *textPassword*, **Default**: *""MUc2B..."*)
   2. `SecureString` with *New SecureString()* as the **Default** value (e.g., **Name**: *secureSecurityToken*, **Default**:*New SecureString()*)
   3. `SecureString` (e.g., **Name**: *securityToken*)
      * For all `SecureString` variables, select the *System.Security.SecurityString* type.
   4. Repeat steps 2-5 to convert your **Security Token** `String` to a `SecureString`.

You should now have three *Create Secure String* sequences in your process, similar to the image below.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-187082-4018594a-a966cfbd.webp)

Now that you have your `SecureString` variables, you can add the **Salesforce Application Scope** activity along with the other Salesforce activities.

#### Add the Salesforce activities
1. Add the [Salesforce Application Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/salesforce-application-scope) activity to your project.
   1. Before you enter your property values, let's test your connection.
      1. Click the **Configure** button (this opens the connection wizard).
      2. Select your **Server** (if connecting to, a developer org or non-developer production org- select "*Live*", a sandbox/test org - select "*Test*").
      3. Enter your **Consumer Key**, **Consumer Secret**, **Username**, **Password**, and **Security Token** (required for developer logins).
      4. Click the **Test Connection** button and wait for the **Connection Successful** window.
         * If you receive an error, make sure that you selected the correct **Server**. Next, try resetting your Security Token by following the last step in the [Get your credentials](https://docs.uipath.com/activities/other/latest/legacy-integrations/uipath-salesforce-sfdc-setup) in the **Setup** guide and enter the new value that's emailed to you.

           ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-179720-f4d30899-c885cd46.webp)
      5. After a successful connection, you can now add your property values, including the `SecureString` variables you created in the steps above (the values entered in the connection wizard are independent of the property values and not shared).
   2. Enter your **ConsumerKey** value (`String`) that you copied when completing the [Get your credentials](https://docs.uipath.com/activities/other/latest/legacy-integrations/uipath-salesforce-sfdc-setup) steps.
   3. In the **ConsumerSecret** property, enter the second `SecureString` variable you created in step 6 above (e.g., *consumerSecret*).
   4. In the **Password** property, enter the second `SecureString` variable you created in step 1 above (e.g., *password*).
   5. Enter your **Server** value (*"Live"* or *"Test"*).
   6. Enter your Salesforce login **Username** (e.g., `"name@company.com"`)
   7. For the **SalesforceConnection** property, create and enter a `IConnectionService` variable (e.g., *salesforceConnection*).
      * You will not use this variable when completing the steps in this guide, but it's good practice to create your output variables for use in subsequent activities.

        ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178227-8c90c7c1-33cf815e.webp)
   8. Add the [Insert Record](https://docs.uipath.com/activities/other/latest/legacy-integrations/insert-record) activity in the **Salesforce Application Scope** activity.
   9. Create a new `String` variable for this activity's output property (e.g., *newAccountID*).
   10. Click the **Configure** button (this opens the Salesforce Object Wizard).
       * To learn more about how the wizard works, see the [Salesforce Object Wizard](https://docs.uipath.com/activities/other/latest/legacy-integrations/about-the-salesforce-activities-pack) section in the **About the Salesforce Activities** page.
   11. In the **Salesforce Object** drop-down list, select *Account* (the **Account ID** and **Name** fields should appear).
   12. In the **Add Single Field** text box, enter *Type* and click Enter (you should now have 3 fields).
   13. In the **Account ID** field, enter the `String` variable you created in step 1 (e.g., *newAcountID*).
   14. Enter a **Name** for the Account (e.g., *"Salesforce Quickstart*").
   15. Enter a valid **Type** `String` (e.g., *"Prospect"*).
       * All fields with a `picklist` **Data Type** require a `String` value that matches an item in the list as shown in the Salesforce user interface.
         + Using the **Type** field as an example, by default the picklist includes the values shown in image below (from the Salesforce Account screen). You can use the [Format Labels And Values](https://docs.uipath.com/activities/other/latest/legacy-integrations/format-labels-and-values) activity to preview the valid `String` values (see example below).

           ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-182873-421839e3-a0aa4212.webp)
       * Click **Done**.

         ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178311-c046e325-094eb8f6.webp)
   16. In the **SalesforceOutput** property, create and enter a `SalesforceStatus` variable (e.g., *insertRecordStatus*).

       ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183277-fa811da9-4f722010.webp)
2. Add the [Upload File](https://docs.uipath.com/activities/other/latest/legacy-integrations/upload-file) activity after the **Insert Record** activity.
   1. Enter your file **Description**, **FilePath**, and **Title**.
   2. In the **OutputID** property, create and enter a new `String` variable (e.g., *newFileID*).
   3. In the **SalesforceStatus** property, create and enter a new `SalesforceStatus` variable (e.g., *uploadFileStatus*).

      ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183409-9540fb46-2fb4e375.webp)
3. Add the [Assign File](https://docs.uipath.com/activities/other/latest/legacy-integrations/assign-file) activity after the **Get Record** activity.
   1. In the **Id** property, enter the `String` variable you created for the **Upload File** activity (e.g., *newFileID*).
   2. In the **RecordId** property, enter the `String` variable you created for the **Insert Activity** activity (e.g., *newAccountID*).
   3. Enter a **ShareType** value (e.g., *"I"* for Inferred).
   4. Enter a **Visibility** value (e.g., *"AllUsers"*).
   5. In the **SalesforceStatus** property, create and enter a new `SalesforceStatus` variable (e.g., *assignFileStatus*).

      ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178444-c593efdd-684e8a3a.webp)

### Test your project

1. To verify that your record was inserted, file uploaded and assigned to the inserted record, add 3 activities after the **Assign File** activity.
   1. In the first **Write Line** activity, enter the following **Text**: *"Insert Record Success: "+insertRecordStatus.Success.ToString*.
      * *insertRecordStatus* is the `SalesforceStatus` variable you created for the **Insert Record** activity.
   2. In the second **Write Line** activity, enter the following **Text**: *"Upload File Success: "+uploadFileSuccess.Success.ToString*.
      * *uploadFileStatus* is the `SalesforceStatus` variable you created for the **Upload File** activity.
   3. In the third **Write Line** activity, enter the following **Text**: *"Upload File Success: "+assignFileSuccess.Success.ToString*.
      * *assignFileStatus* is the `SalesforceStatus` variable you created for the **Assign File** activity.
   4. Click **Start** and verify the results in the output window.

      ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-179988-ec7fdd80-d8587ec4.webp)
2. To further verify your results, login to your Salesforce Org and go to your **Accounts** and **Files** to see your new additions.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178376-3dcf6393-23b54f17.webp)

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183361-6a497e31-f51d6183.webp)

You're done! You now have an automation project that includes Salesforce activities. To learn more about the Salesforce activities, see [Activities](https://docs.uipath.com/activities/other/latest/legacy-integrations/salesforce-activities) for links to the activity detail pages.

To further your Salesforce automation, see the [UiPath Connector for Salesforce](https://docs.uipath.com/integrations/docs/salesforce-about) documentation. The UiPath Connector for Salesforce creates a “server – server” connection between Salesforce and UiPath Orchestrator (on-prem or Cloud instances). It gives you the ability to submit UiPath Jobs or add Queue items from Salesforce via Flow Builder, Process Builder, or Workflow.
