Salesforce

Overview


Use the Salesforce integration to search, query, and add new objects (tasks, accounts, cases, and so on) to Salesforce directly from Demisto.

The fetch incident option enables you to monitor the creation of new Salesforce cases and manage them in Demisto.

Use cases


Search for data: !salesforce-search pattern=”1234”

This command will return all relevant objects containing the string 1234 as a part of their data.

Querying the data base: !salesforce-query query=“SELECT Subject,Description FROM User WHERE CreatedDate>2018-01-01T00:00:00Z”

This command will return the subject and description of all cases that were created in 2018.

Creating Cases: !salesforce-add-case status="On Hold" subject="adding case from command add-case" type="Feature Request" priority=Low

This command will create a new Salesforce case with the given data.

Submitting Chatter message: !salesforce-push-comment oid=5003600000Smg4sAAB text="adding comment to case" link="google.com"

This command will add a new comment to the object oid and result with the following comment.
image

Configure Salesforce to Work with Demisto


  1. Add a new connected App in Salesforce. For more information, see the Salesforce documentation .
  2. If you already have a connected App, navigate to Setup > App Manager and select the correct App from the list, and click View .
  3. You can find the Consumer Key / Secret under API (Enable OAuth Settings).
    For detailed instructions see the Credentials walkthrough section.

Configure the Salesforce Integration on Demisto


  1. Navigate to Settings > Integrations > Servers & Services .
  2. Search for Salesforce.
  3. Click Add instance to create and configure a new integration instance.
    • Name : a textual name for the integration instance.
    • Instance URL : A URL to the instance.
    • Credentials : The username for accessing the instance
    • Consumer Key : The Consumer Key set for this integration with Demisto, as explained in 'Setting Salesforce'
    • Consumer Secret : The Consumer Secret set for this integration with Demisto, as explained in 'Setting Salesforce' above.
    • Trust any certificate (not secure)
    • Fetch type: cases/comments (Only fetch comments when using the SalesforceAskUser automation)
    • Use system proxy settings
    • Fetch incidents
    • Incident type
  4. Click Test to validate the URLs, token, and connection.

Fetched Incidents Data


The fetch command monitors the creation of new cases starting from the time the option was enabled.

Commands


You can execute these commands from the Demisto CLI, as part of an automation, or in a playbook. After you successfully execute a command, a DBot message appears in the War Room with the command details.

  1. Search Salesforce records: salesforce-search
  2. Perform a query using SOQL: salesforce-query
  3. Get an object: salesforce-get-object
  4. Update an object: salesforce-update-object
  5. Create an object: salesforce-create-object
  6. Add a comment to chatter: salesforce-push-comment
  7. Get case information: salesforce-get-case
  8. Create a case: salesforce-create-case
  9. Update a case: salesforce-update-case
  10. Get all cases: salesforce-get-cases
  11. Close a case: salesforce-close-case
  12. Add a comment to a chatter thread: salesforce-push-comment-threads
  13. Delete a case: salesforce-delete-case

1. Search Salesforce records


Search records that contain values with pattern.

Base Command

salesforce-search

Input
Argument Name Description Required
pattern String or number to search Required
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case number
SalesForce.Case.Subject string Case subject
SalesForce.Case.Description string Case description
SalesForce.Case.CreateDate date Time the case was created
SalesForce.Case.ClosedDate date Time the case was closed
SalesForce.Case.Owner string Case owner
SalesForce.Case.Priority string Case priority (Low, Medium, High)
SalesForce.Case.Origin string How case originated (Web, Phone, Email)
SalesForce.Case.Status string Case status (New, Escalated, On Hold, or Closed)
SalesForce.Case.Reason string Reason the case was created
SalesForce.Contact.ID string Contact ID
SalesForce.Contact.Name string Contact name
SalesForce.Contact.Account string Account associated with the contact information
SalesForce.Contact.Title string Contact title
SalesForce.Contact.Phone string Contact phone number
SalesForce.Contact.MobliePhone string Contact mobile number
SalesForce.Contact.Email string Contact email address
SalesForce.Contact.Owner string Contact owner
SalesForce.Lead.ID string Lead ID
SalesForce.Lead.Name string Lead name
SalesForce.Lead.Title string Lead title
SalesForce.Lead.Company string Lead company
SalesForce.Lead.Phone string Lead phone number
SalesForce.Lead.Mobile string Lead mobile number
SalesForce.Lead.Email string Lead email address
SalesForce.Lead.Owner string Lead owner
SalesForce.Lead.Status string Lead status (New, Nurturing, Working, Qualified, or Unqualified)
SalesForce.Task.ID string Task ID
SalesForce.Task.Subject string Task subject
SalesForce.Task.Lead string Task leader
SalesForce.Task.RelatedTo string Relevant account
SalesForce.Task.DueDate date Task due date
SalesForce.User.ID string User's ID
SalesForce.User.Name string User's name
SalesForce.User.Title string User's title
SalesForce.User.Phone string User's phone number
SalesForce.User.Email string User's email address

2. Perform a query using SOQL


Query Salesforce with SOQL

Base Command

salesforce-query

Input
Argument Name Description Required
query Query in SOQL format: "SELECT name from Account" Required
Context Output

There is no context output for this command.

Command Example

image

3. Get an object


Get object by path

Base Command

salesforce-get-object

Input
Argument Name Description Required
path Object path, for example: "Case/5000Y000001EjzRQAS" for Object "Case" with ID "5000Y000001EjzRQAS" Required
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case number
SalesForce.Case.Subject string Case subject
SalesForce.Case.Description string Case description
SalesForce.Case.CreateDate date Time the case was created
SalesForce.Case.ClosedDate date Time the case was closed
SalesForce.Case.Owner string Case owner
SalesForce.Case.Priority string Case priority (Low, Medium, High)
SalesForce.Case.Origin string How case originated (Web, Phone, Email)
SalesForce.Case.Status string Case status (New, Escalated, On Hold, or Closed)
SalesForce.Case.Reason string Reason the case was created
SalesForce.Contact.ID string Contact ID
SalesForce.Contact.Name string Contact name
SalesForce.Contact.Account string Account associated with the contact information
SalesForce.Contact.Title string Contact title
SalesForce.Contact.Phone string Contact phone number
SalesForce.Contact.MobliePhone string Contact mobile number
SalesForce.Contact.Email string Contact email address
SalesForce.Contact.Owner string Contact owner
SalesForce.Lead.ID string Lead ID
SalesForce.Lead.Name string Lead name
SalesForce.Lead.Title string Lead title
SalesForce.Lead.Company string Lead company
SalesForce.Lead.Phone string Lead phone number
SalesForce.Lead.Mobile string Lead mobile number
SalesForce.Lead.Email string Lead email address
SalesForce.Lead.Owner string Lead owner
SalesForce.Lead.Status string Lead status (New, Nurturing, Working, Qualified, or Unqualified)
SalesForce.Task.ID string Task ID
SalesForce.Task.Subject string Task subject
SalesForce.Task.Lead string Task leader
SalesForce.Task.RelatedTo string Relevant account
SalesForce.Task.DueDate date Task due date
SalesForce.User.ID string User ID
SalesForce.User.Name string User's name
SalesForce.User.Title string User's title
SalesForce.User.Phone string User's phone number
SalesForce.User.Email string User's email
Command Example
Context Example
Human Readable Output

4. Update an object


Update object fields

Base Command

salesforce-update-object

Input
Argument Name Description Required
path Object path, for example: "Case/5000Y000001EjzRQAS" for Object "Case" with ID "5000Y000001EjzRQAS" Required
json JSON with fields and values of the object to be updated Required
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case number
SalesForce.Case.Subject string Case subject
SalesForce.Case.Description string Case description
SalesForce.Case.CreateDate date Time case was created
SalesForce.Case.ClosedDate date Time case was closed
SalesForce.Case.Owner string Case owner
SalesForce.Case.Priority string Case priority (Low, Medium, High)
SalesForce.Case.Origin string How case originated (Web, Phone, Email)
SalesForce.Case.Status string Case status (New, Escalated, On Hold, or Closed)
SalesForce.Case.Reason string Reason the case was created
SalesForce.Contact.ID string Contact ID
SalesForce.Contact.Name string Contact name
SalesForce.Contact.Account string Account associated with the contact information
SalesForce.Contact.Title string Contact title
SalesForce.Contact.Phone string Contact phone number
SalesForce.Contact.MobliePhone string Contact mobile number
SalesForce.Contact.Email string Contact email address
SalesForce.Contact.Owner string Contact owner
SalesForce.Lead.ID string Lead ID
SalesForce.Lead.Name string Lead name
SalesForce.Lead.Title string Lead title
SalesForce.Lead.Company string Lead company
SalesForce.Lead.Phone string Lead phone number
SalesForce.Lead.Mobile string Lead mobile number
SalesForce.Lead.Email string Lead email address
SalesForce.Lead.Owner string Lead owner
SalesForce.Lead.Status string Lead status (New, Nurturing, Working, Qualified, or Unqualified)
SalesForce.Task.ID string Task ID
SalesForce.Task.Subject string Task subject
SalesForce.Task.Lead string Task leader
SalesForce.Task.RelatedTo string Relevant account
SalesForce.Task.DueDate date Task due date
SalesForce.User.ID string User's ID
SalesForce.User.Name string User's name
SalesForce.User.Title string User's title
SalesForce.User.Phone string User's phone number
SalesForce.User.Email string User's email

5. Create an object


Create new object

Base Command

salesforce-create-object

Input
Argument Name Description Required
path Object path, for example: "Case" for Object "Case" Required
json JSON with fields and values of the object to be created Required
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case number
SalesForce.Case.Subject string Case subject
SalesForce.Case.Description string Case description
SalesForce.Case.CreateDate date Time case was created
SalesForce.Case.ClosedDate date Time case was closed
SalesForce.Case.Owner string Case owner
SalesForce.Case.Priority string Case priority (Low, Medium, High)
SalesForce.Case.Origin string How case originated (Web, Phone, Email)
SalesForce.Case.Status string Case status (New, Escalated, On Hold, or Closed)
SalesForce.Case.Reason string Reason the case was created
SalesForce.Contact.ID string Contact ID
SalesForce.Contact.Name string Contact name
SalesForce.Contact.Account string Account associated with the contact information
SalesForce.Contact.Title string Contact title
SalesForce.Contact.Phone string Contact phone number
SalesForce.Contact.MobliePhone string Contact mobile number
SalesForce.Contact.Email string Contact email
SalesForce.Contact.Owner string Contact owner
SalesForce.Lead.ID string Lead ID
SalesForce.Lead.Name string Lead name
SalesForce.Lead.Title string Lead title
SalesForce.Lead.Company string Lead company
SalesForce.Lead.Phone string Lead phone number
SalesForce.Lead.Mobile string Lead mobile number
SalesForce.Lead.Email string Lead email
SalesForce.Lead.Owner string Lead owner
SalesForce.Lead.Status string Lead status (New, Nurturing, Working, Qualified, or Unqualified)
SalesForce.Task.ID string Task ID
SalesForce.Task.Subject string Task subject
SalesForce.Task.Lead string Task leader
SalesForce.Task.RelatedTo string Relevant account
SalesForce.Task.DueDate date Task due date
SalesForce.User.ID string User's ID
SalesForce.User.Name string User's name
SalesForce.User.Title string User's title
SalesForce.User.Phone string User's hone number
SalesForce.User.Email string User's email address

6. Add a comment to chatter


Add a comment to chatter

Base Command

salesforce-push-comment

Input
Argument Name Description Required
oid Object ID of subject Required
text Chat text Required
link Add a link to the message Optional
Context Output
Path Type Description
SalesForce.Comment.Body string Comment body
SalesForce.Comment.CreatedDate date Comment created date
SalesForce.Comment.Title string Comment title
SalesForce.Comment.ParentType string Comment parent type
SalesForce.Comment.ParentName string Comment parent name
SalesForce.Comment.URL string Comment URL link
SalesForce.Comment.Visibility string Comment visibility
Command Example

image

Context Example

image

7. Get case information


Get information for a specified on a case. All arguments are optional, but you must specify at least one for the command to execute successfully.

Base Command

salesforce-get-case

Input
Argument Name Description Required
oid Object ID of the case Optional
caseNumber Case number Optional
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case number
SalesForce.Case.Subject string Case subject
SalesForce.Case.Description string Case description
SalesForce.Case.CreateDate date Time case was created
SalesForce.Case.ClosedDate date Time case was closed
SalesForce.Case.Owner string Case owner
SalesForce.Case.Priority string Priority of the case (Low, Medium, High)
SalesForce.Case.Origin string How case originated (Web, Phone, Email)
SalesForce.Case.Status string Case status (New, Escalated, On Hold, or Closed)
SalesForce.Case.Reason string Reason the case was created
Command Example

image

Context Example

image

8. Create a case


Create a new case

Base Command

salesforce-create-case

Input
Argument Name Description Required
subject Case subject Required
description Case description Optional
status Case status Required
origin Case origin Optional
priority Case priority Optional
type Case type Optional
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case number
SalesForce.Case.Subject string Case subject
SalesForce.Case.Description string Case description
SalesForce.Case.CreateDate date Time case was created
SalesForce.Case.ClosedDate date Time case was closed
SalesForce.Case.Owner string Case owner
SalesForce.Case.Priority string Priority of the case (Low, Medium, High)
SalesForce.Case.Origin string How case originated (Web, Phone, Email)
SalesForce.Case.Status string Case status (New, Escalated, On Hold, or Closed)
SalesForce.Case.Reason string Reason for case creation

9. Update a case


Update case fields

Base Command

salesforce-update-case

Input
Argument Name Description Required
oid Case Object ID Optional
caseNumber Case number Optional
subject Case subject Optional
description Case description Optional
status Case status Optional
origin Case origin Optional
priority Case priority Optional
type Case type Optional
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case number
SalesForce.Case.Subject string Case subject
SalesForce.Case.Description string Case description
SalesForce.Case.CreateDate date Time case was created
SalesForce.Case.ClosedDate date Time case was closed
SalesForce.Case.Owner string Case owner
SalesForce.Case.Priority string Priority of the case (Low, Medium, High)
SalesForce.Case.Origin string How case originated (Web, Phone, Email)
SalesForce.Case.Status string Case status (New, Escalated, On Hold, or Closed)
SalesForce.Case.Reason string Reason the case was created

10. Get all cases


Get all cases

Base Command

salesforce-get-cases

Input

There is no input for this command.

Context Output

There is no context output for this command.

11. Close a case


Close a case

Base Command

salesforce-close-case

Input
Argument Name Description Required
oid Case Object ID Optional
caseNumber Case Number Optional
Context Output
Path Type Description
SalesForce.Case.ID string Case Object ID
SalesForce.Case.CaseNumber string Case Number
SalesForce.Case.Subject string Case Subject
SalesForce.Case.Description string Case Description
SalesForce.Case.CreateDate date Creation Time of Case
SalesForce.Case.ClosedDate date Closure Time of Case
SalesForce.Case.Owner string Case Owner
SalesForce.Case.Priority string Priority of the Case. one of Low, Medium, High.
SalesForce.Case.Origin string Origin of the Case. one of Web, Phone, Email.
SalesForce.Case.Status string Case Status. one of the following: New, Escalated, On Hold or Closed.
SalesForce.Case.Reason string Reason for case creation
Command Example

image

12. Add a comment to a chatter thread


Add the comment to the chatter thread. Use this command only after salesforce-push-comment

Base Command

salesforce-push-comment-threads

Input
Argument Name Description Required
id The Chatter comment Thread ID Required
text The comment text Required
Context Output
Path Type Description
SalesForce.Comment.Reply.Body string Reply body
SalesForce.Comment.Reply.CreatedDate date Reply created date
SalesForce.Comment.Reply.URL string Reply URL link

13. Delete a case


Delete a specified on a case. All arguments are optional, but you must specify at least one for the command to execute successfully.

Base Command

salesforce-get-case

Input
Argument Name Description Required
oid Object ID of the case Optional
caseNumber Case number Optional

Troubleshooting


Connection error :

  • This error indicates that there is a problem with the credentials or the IP connection to the app (see step 6-7 in Credentials walkthrough below).



  • This error indicates a problem in the Costumer Key:



  • This error indicates a problem in the Costumer Secret:


Credentials walkthrough:

1. Open Setup .

2. Go to the App manager on the left side menu (use Quick Find for faster search).

3. Click “New Connected App” on the right side of the screen.

4. Fill in the form as follows:

  • Mark “ Enable OAuth Settings ”.
  • In “ Selected OAuth Scopes ”, Add the following:
    • Access and manage your Chatter data (chatter_api)
    • Access and manage your data (api)

5. Click “Save” at the bottom of the form.

6. In the information page on the APP that you will be forwarded to locate “ API (Enable OAuth Settings) ” and copy the consumer key and secret to the integration instance configuration.

6. Go to “Manage Connected Apps”.

7. Edit the new application and under “OAuth Policies” enable all IP address.