Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Salesforce updates #729

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions how-to/integrate-with-salesforce/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Once you have completed the configuration steps, update the `customSettings` sec

- **`orgUrl`**: the URL of your Salesforce org (ending in "my.salesforce.com")
- **`consumerKey`**: the Consumer Key of the Connected App you just created
- **`contextGroupStrategy`**: When you launch a result from home do you want to assign a context group to the view. Options are: none, first, rotation (rotation is the default)

Optionally, if the enhanced notes feature is [enabled](https://help.salesforce.com/s/articleView?id=sf.notes_admin_setup.htm&type=5), this sample will include notes in the search results displayed in Home.

Expand Down
6 changes: 3 additions & 3 deletions how-to/integrate-with-salesforce/client/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function interopOverride(InteropBroker: OpenFin.Constructor<OpenFin.InteropBroke
public async handleFiredIntent(intent: OpenFin.Intent): Promise<void> {
console.log("Received request for a raised intent:", intent);

if (intent.name === "ViewContact") {
if (intent.name === "ViewContact" || intent.name === "ViewProfile") {
const viewIdentity = { uuid: fin.me.identity.uuid, name: "fdc3-intent-view" };
let hasView = false;
try {
Expand All @@ -181,8 +181,8 @@ function interopOverride(InteropBroker: OpenFin.Constructor<OpenFin.InteropBroke
const platform = getCurrentSync();
await platform.createView({
name: "fdc3-intent-view",
url: " https://built-on-openfin.github.io/dev-extensions/extensions/v18.0.0/interop/fdc3/intent/fdc3-intent-view.html",
fdc3InteropApi: "1.2",
url: "https://built-on-openfin.github.io/dev-extensions/extensions/v18.0.0/interop/fdc3/intent/2-0/fdc3-intent-view.html",
fdc3InteropApi: "2.0",
interop: {
currentContextGroup: "green"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ export class SalesforceIntegration {
*/
private _integrationHelpers: IntegrationHelpers | undefined;

/**
* Context groups for the module when launching content.
*/
private _contextGroups: string[] | undefined;

/**
* Last context group index.
*/
private _contextGroupIndex: number = -1;

/**
* The module definition.
* @internal
Expand Down Expand Up @@ -763,13 +773,16 @@ export class SalesforceIntegration {
* @param data The data to use for opening.
*/
private async openSalesforceContent(data: SalesforceResultData): Promise<void> {
const interop: OpenFin.InteropConfig = {
currentContextGroup: "green"
};
const currentContextGroup = await this.getCurrentContextGroup();
const interop: OpenFin.InteropConfig | undefined = currentContextGroup
? {
currentContextGroup
}
: undefined;
const customData = { buttonLabel: "Process Participant" };
const url = data.url;

if (this._settings?.appId && this._integrationHelpers?.launchApp) {
if (this._settings?.appId && this._settings?.appId.length > 0 && this._integrationHelpers?.launchApp) {
await this._integrationHelpers?.launchApp(this._settings.appId, {
options: {
type: "view",
Expand All @@ -784,7 +797,7 @@ export class SalesforceIntegration {
const preload = this._settings?.preload;
const viewOptions: OpenFin.PlatformViewCreationOptions = {
url,
fdc3InteropApi: "1.2",
fdc3InteropApi: "2.0",
interop,
customData,
preloadScripts: [{ url: preload ?? "" }]
Expand Down Expand Up @@ -1623,6 +1636,52 @@ export class SalesforceIntegration {
return finalActions;
}

/**
* Populate the context groups for the integration.
*/
private async populateContextGroups(): Promise<void> {
if (this._contextGroups === undefined) {
if (this._integrationHelpers?.getInteropClient) {
const interopClient = await this._integrationHelpers.getInteropClient();
if (interopClient) {
this._contextGroups = [];
const contextGroups = await interopClient.getContextGroups();
for (const contextGroup of contextGroups) {
this._contextGroups.push(contextGroup.id);
}
}
}
if (this._contextGroups === undefined) {
// if the context groups are still undefined, set the default
this._contextGroups = ["green"];
}
}
}

/**
* Returns the context group to use for the integration.
* @returns The context group to use.
*/
private async getCurrentContextGroup(): Promise<string | undefined> {
await this.populateContextGroups();
if (
this._contextGroups === undefined ||
this._contextGroups.length === 0 ||
this._settings?.contextGroupStrategy === "none"
) {
return undefined;
}
if (this._settings?.contextGroupStrategy === "first") {
return this._contextGroups[0];
}

if (this._contextGroupIndex === this._contextGroups.length) {
this._contextGroupIndex = -1;
}
this._contextGroupIndex++;
return this._contextGroups[this._contextGroupIndex];
}

/**
* Deep clone an object.
* @param obj The object to clone.
Expand Down
8 changes: 8 additions & 0 deletions how-to/integrate-with-salesforce/client/src/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ export interface SalesforceSettings {
*/
appId?: string;

/**
* Content Context Group
* none - a context group is not assigned to the content
* first - the first context group of available context groups is always assigned.
* rotation - the context group is rotated through the available context groups.
*/
contextGroupStrategy?: "none" | "first" | "rotation";

/**
* Map the data from SF to templates, if you just include the type field the default display will be used.
*/
Expand Down
1 change: 1 addition & 0 deletions how-to/integrate-with-salesforce/public/manifest.fin.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"orgUrl": "",
"enableLibLogging": true,
"preload": "http://localhost:8080/js/preload.js",
"contextGroupStrategy": "rotation",
"iconMap": {
"salesforce": "http://localhost:8080/images/salesforce.svg",
"contact": "http://localhost:8080/images/contact.svg",
Expand Down
1 change: 1 addition & 0 deletions how-to/workspace-platform-starter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## v18.0.0

- Added [apps-connector.json](./public/common/apps-connector.json) which includes an example salesforce app that can be added as the appId in the salesforce integration in the main [manifest.fin.json](./public/manifest.fin.json). The [apps-connector.json](./public/common/apps-connector.json) directory would also need to be added to the appProvider for it to be loaded. See [how to use our integrations](./docs/how-to-setup-example-home-integrations.md)
- Updated WPS Interop Broker implementation so that it includes fdc3 app instances if they exist in the array of apps returned when findIntent is called as recommended by the FDC3 documentation.
- Extended endpoint so that we now have a requestStream option for those implementing endpoints that want to return a stream of data instead of a simply requestResponse.
- Included an example of the the requestStream endpoint by implementing an example source of notification data in the [client/src/modules/endpoint/example-notification-source](./client/src/modules/endpoint/example-notification-source/endpoint.ts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Our Salesforce example already exists in the main [manifest.fin.json](../public/
"enabled": false,
"url": "https://built-on-openfin.github.io/workspace-starter/workspace/v18.0.0/integrate-with-salesforce/js/modules/integrations/salesforce.bundle.js",
"data": {
"appId": "",
"consumerKey": "",
"orgUrl": "",
"preload": "https://built-on-openfin.github.io/workspace-starter/workspace/v18.0.0/integrate-with-salesforce/js/preload.js",
Expand All @@ -42,6 +43,17 @@ This examples supports a number of configuration settings (covered in the sample

![Salesforce](./assets/home-salesforce.png)

### Add Intent Support to search results

If you wish to have content launched from the Salesforce integration to be an intent target for ViewContact/ViewProfile then you will need:

- An app definition - We have included one in [apps-connector.json](../public/common/apps-connector.json) although you will need to add your salesforce org url. You will also need to add the [apps-connector.json](../public/common/apps-connector.json) directory to your [appsProvider](./what-is-an-apps-provider.md) so that it is included when looking up which applications support ViewContact/ViewProfile.
- Add the appId (salesforce-app is the id we use in our apps-connector.json file) to the salesforce integration entry in your manifest or settings file. This will tell the integration to launch Salesforce urls as part of the app.

### Preload scripts

In the integration definition and the salesforce app definition you will see a reference to preload scripts. If you are using a [Lightning Web Security Salesforce application](https://developer.salesforce.com/docs/platform/lwc/guide/security-lwsec-intro.html) then you can delete the preload script entries as they are not needed. For more information about the OpenFin SalesForce app which simplifies Salesforce integration please visit: <https://developers.openfin.co/of-docs/docs/salesforce-appexchange>.

## ServiceNow

Our ServiceNow example already exists in the main [manifest.fin.json](../public/manifest.fin.json) in the integrationProvider section. It is disabled and would need to be enabled and the details about your ServiceNow setup would need to be added.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[
{
"appId": "salesforce-app",
"name": "salesforce-app",
"title": "Salesforce",
"description": "If you are using the OpenFin Salesforce App on the app exchange then you can make it an intent target and add an app entry for it.",
"manifest": {
"url": "",
"fdc3InteropApi": "2.0",
"preloadScripts": [
{
"url": "https://built-on-openfin.github.io/workspace-starter/workspace/v18.0.0/integrate-with-salesforce/js/preload.js"
}
]
},
"manifestType": "inline-view",
"icons": [],
"contactEmail": "[email protected]",
"supportEmail": "[email protected]",
"publisher": "OpenFin",
"intents": [
{
"name": "ViewContact",
"displayName": "View Contact",
"contexts": ["fdc3.contact"]
},
{
"name": "ViewProfile",
"displayName": "View Profile",
"contexts": ["fdc3.contact", "fdc3.organization"]
}
],
"private": true,
"images": [],
"tags": ["fdc3", "interop", "contact", "salesforce"],
"launchPreference": {
"options": {
"type": "view",
"updatable": [
{
"name": "url",
"constraint": "url-domain"
},
{ "name": "interop" }
]
}
}
}
]
1 change: 1 addition & 0 deletions how-to/workspace-platform-starter/public/manifest.fin.json
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@
"enabled": false,
"url": "https://built-on-openfin.github.io/workspace-starter/workspace/v18.0.0/integrate-with-salesforce/js/modules/integrations/salesforce.bundle.js",
"data": {
"appId": "",
"consumerKey": "",
"orgUrl": "",
"preload": "https://built-on-openfin.github.io/workspace-starter/workspace/v18.0.0/integrate-with-salesforce/js/preload.js",
Expand Down
Loading