HomeGuidesAPI ReferenceChangelogDiscussions
Log In

SalesForce

SalesForce CLI

This CLI is provided to perform batch processing and ticket assignment using the SalesForce Platfrom. It is designed to perform bulk processing of RegScale issues to create, update, and otherwise sync with SalesForce and vice versa to perform automated case assignment. The CLI currently supports the below functionality:

  • sync - syncs issues from RegScale and auto-assigns cases in SalesForce while cross-linking their IDs

Init.yaml Configuration

There are multiple pieces of information needed to configure the SalesForce integration via the CLI:

  • salesForceUserName - Your User Name in SalesForce, you can also use an environment variable as SF_USERNAME
  • salesForcePassword - Password for SalesForce, you can also use an environment variable as SF_PASSWORD
  • salesForceToken - Security token for SalesForce, you can also use an environment variable as SF_TOKEN
  • maxThreads - The total number of threads the application is allowed to use for bulk processing data into RegScale. The default value is 1000. (NOTE: Changing this number can have a negative or positive impact on performance.)

The first step is to get your security token from SalesForce for your SalesForce account. The Security Token can be reset and emailed to you by following these steps: SalesForce Help . An example Secret Key is as follows: kfkuVw1GgkyAXXXXXXXXXXXXXXXXXXXX. This security token can be placed in your init.yaml or as an environment variable as SF_TOKEN.

You can store your SalesForce username and password in the init.yaml as salesForceUserName and salesForcePassword or you can store them as environment variables: SF_USERNAME and SF_PASSWORD. You also have the option of storing parts of the credentials as environment variables and values in the init.yaml

Issue Processing Workflow

The CLI currently supports processing RegScale issues to create SalesForce cases. The issue processing workflow is shown below:

  • The user first logs into RegScale via the CLI to set the access token or otherwise creates a service account as described in the CLI Login documentation
  • The user then calls the CLI to process SalesForce cases while setting the following flags:
    • regscale_id - the ID # of the RegScale record associated with these issues
    • regscale_module - the RegScale module of the record associated with these issues, please view RegScale Modules for options.
    • sf_status - specify the the SalesForce status to filter for exclusively or exclude (to be combined with not_equal
    • not_equal - A true flag that will get all SalesForce case statuses that do not equal the provided sf_status
    • sync_attachments - Whether to sync attachments between SalesForce and RegScale, defaults to True
  • The CLI then retrieves all existing issues in RegScale for the key value pair provided above
  • The CLI then retrieves all cases in SalesForce
  • The CLI then processes through all retrieved SalesForce cases and does the following:
    • Sees if SalesForce has the case in RegScale, if not a case is created in SalesForce with the status New and the issue in RegScale is updated to include the new SalesForce Case Number
    • Sees if RegScale has all the cases from SalesForce, if not it is created in RegScale with the information associated with the case in SalesForce
    • If the case already exists in both SalesForce and RegScale they are compared against one another and updated
    • When using sync_attachments as True, the attachments for both the RegScale issue and SalesForce case are compared to prevent duplication and the attachments will match in both Regscale and SalesForce

The CLI provides detailed logging throughout the process to indicate progress and to provide troubleshooting in case of problems.

Issue CLI Command Example

The following command provides an example of processing Sales cases for a given RegScale System Security Plan (SSP). These commands can be easily adapted for the customer's specific use case. The steps are shown below:

  • Log into RegScale to set the token which is good for 24 hours and will secure all future RegScale API calls (NOTE: You can skip this step if you are using a RegScale Service Account)
regscale login
  • Process the appropriate level of issues for the given record, this example will get all cases from SalesForce that do not have a status of Closed
regscale sales_force sync --regscale_id=5 --regscale_module="securityplans" --sf_status="Closed" --not-equal

Init.yaml Example

For a basic SalesForce integration with RegScale, the following init.yaml structure is necessary (example/notional key structure shown below, replace with actual customer keys):

domain: https://mycompany.regscale.com
token: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC38.eyJzdWIiOiJob3dpZWF2cCIsImp0aSI6ImI0NDIxMjRhLTYxOWEtNGI1Mi1hMzUzLTA5YzdjZTRmM2JmOCIsImlhdCI6MTY0NDc4NzY4MiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbmFtZWlkZW50aWZpZXIiOiJjOWY1NzllMi1hOGM4LTRjMDItOGU5MS1jZTEyMmExYWE1MTciLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiaG93aWVhdnAiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJBZG1pbmlzdHJhdG9yIiwibmJmIjoxNjQ0Nzg3NjgyLCJleHAiOjE2NDQ4NzQwODIsImlzcyI6IkF0bGFzIiwiYXVkIjoiaHR0cDovL2xvY2FsaG9zdDo1MDAwLyJ9.SkjmRktGLkljysVeoRqcx_hHiVR2gjcA2uZiSJbVkPc
maxThreads: 1000
userId: c9f579e2-a8c9-4c02-8e91-ce122a1aa518
salesForceUserName: [email protected]
salesForcePassword: SuperSecretPassword!
salesForceToken: g4iyZh9zdcxocqod714

Environment Varibles Example

[email protected]
SF_PASSWORD=SuperSecretPassword!
SF_TOKEN=g4iyZh9zdcxocqod714

Building a Bash Script to Execute the CLI

You can chain together RegScale CLI commands using scripts. These scripts could be in Bash, Python, PowerShell, etc. Below is an example Bash file (named "regscaleScheduler.sh") in Ubuntu for executing the SalesForce CLI that pulls all cases after authenticating and syncs them to a module and ID in RegScale as issues:

#!/bin/sh
regscale login
regscale sales_force sync --regscale_id=5 --regscale_module="securityplans" --sf_status="New"

To execute the Bash file, run this command: . regscaleScheduler.sh. You can chain together any arbitrary set of CLI commands to have them execute sequentially.