Skip to content

Commit

Permalink
Create Salesforce-Integration.md (#38)
Browse files Browse the repository at this point in the history
* Create Salesforce-Integration.md

This is the first draft and needs to be validated by someone who has completed the integration.   The information is accurate, but it might not include all the steps specific to the Salesforce Integration.

* Update Integrations.md

adding link to Salesforce-Integration page

* adding documentation for Integration of sales force external services

* fix typo.

---------

Co-authored-by: “bhuvan-aot” <“[email protected]”>
  • Loading branch information
matthewhall78 and “bhuvan-aot” committed Jul 8, 2024
1 parent a65d73e commit 797e3bc
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions docs/Capabilities/Integrations/Salesforce-Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,54 @@

Salesforce is one of many ways to work with form submission data.

## Salesforce Integration
## Salesforce Integration using Named Credentials and External Services

By creating a new Salesforce query you can work with the submission data.
By creating a new Salesforce External service you can work with the submission data.

### CHEFS Form Information

You will need this information about your form:
- The `formId` and `formVersionId`. One way to retrieve them is to "Manage" your form and in the table at the bottom click "Version 1" (or the version you want). The URL in the new browser window will contain ".../preview?f={formId}&v={formVersionId}"
- Your form's [API Key](../Data-Management/Generating-API-keys)

### Salesforce Configuration: Submissions
### Named Credentials in salesforce

- Use Salesforce to `Get data` from a URL or `Web` location
- Use the URL `https://submit.digital.gov.bc.ca/app/api/v1/forms/{formId}/versions/{formVersionId}/submissions` to get the submissions for a version of your form - you will need to replace `{formId}` and `{formVersionId}` with the values for your form
- The type of authentication to use is "Basic".
- "User name" will be set to your `formId`
- "Password" will be set to your API Key
**Named Credentials** allow Salesforce to manage authentication for calls to external systems. This simplifies the process of calling an external APIs by securely storing authentication details and abstracting the complexity of API authentication.

### Salesforce Configuration: Submission Statuses
**Steps to Create Named Credentials:**

It is also possible to get the list of statuses for each submission.
1. **Navigate to:** Setup > Named Credentials
2. **Click on:** New Named Credential
3. **Fill in the Details:**
- **Label:** Enter a name for the credential (e.g., "CHEFSAPICredential").
- **Name:** This is automatically populated based on the label.
- **URL:** Enter the base URL of the external API as `https://submit.digital.gov.bc.ca/app/api/v1`
- **Identity Type:** Select `Named Principal`
- **Authentication Protocol:** Select `Basic Authentication`.
- **Username:** Enter the API username. It will be `formId` in our case.
- **Password:** "Password" will be set to your form [API Key](../Data-Management/Generating-API-keys)

- Use Salesforce to `Get data` from a URL or `Web` location
- Use the URL `https://submit.digital.gov.bc.ca/app/api/v1/submissions/{formSubmissionId}/status` to get the statuses for each submission - you will need to replace `{formSubmissionId}` with the `id` value for each submission
- The type of authentication to use is "Basic".
- "User name" will be set to your `formId`
- "Password" will be set to your API Key
4. **Save:** This securely stores the authentication details for accessing the external API.

### External Services in salesforce

**External Services** in Salesforce allow you to connect to external APIs using a declarative approach.

**Steps to Create an External Service:**

1. **Navigate to:** Setup > External Services
2. **Click on:** New External Service
3. On the Select an API Source page, select whether you’re importing an API spec From Mulesoft Anypoint Platform, or From API Specification. Since we're using CHEFS spec here, select From API Specification.
4. **Fill in the Details:**
- **Service Name:** Enter a name for the external service (e.g., "CHEFSAPIService").
- **Named Credential:** Select the named credential you created earlier i.e. `CHEFSAPICredential`
- **Service Schema:** Select `Relative URL`.
- **URL**: Enter `/api-spec.yaml`, provides the Open API specification for all CHEFS API's. Any API's with Authorization as Basic Auth can be integrated with the salesforce External Services. Following are some of useful API's
- Enter `/forms/{formId}/versions/{formVersionId}/submissions` to get the submissions for a version of your form - you will need to replace `{formId}` and `{formVersionId}` with the values for your form.
- Enter `/submissions/{formSubmissionId}/status` to get the statuses for each submission - you will need to replace `{formSubmissionId}` with the `id` value for each submission.

5. **Save & Next:** Salesforce will parse the OpenAPI specification and generate Apex actions.
6. You can now integrate and work with CHEFS data using the newly added External Service in your Apex code, Flow Builder, Process Builder, or any other Salesforce components that support External Service.

***
[Terms of Use](Terms-of-Use) | [Privacy](Privacy) | [Security](Security) | [Service Agreement](Service-Agreement) | [Accessibility](Accessibility)

0 comments on commit 797e3bc

Please sign in to comment.