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

Dev/john/salesforce update #635

Merged
merged 3 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class SalesforceIntegration {
const action = data.mapping?.actions?.[actionIdx];

if (!action?.url && !action?.intent && !action?.view) {
await this.openSalesforceView(data);
await this.openSalesforceContent(data);
} else if (action.url) {
await fin.System.openUrlWithBrowser(
this.substituteProperties(data.mapping, data.obj, action.url, true)
Expand Down Expand Up @@ -355,7 +355,7 @@ export class SalesforceIntegration {
await fin.System.openUrlWithBrowser(u);
}
} else {
await this.openSalesforceView(data);
await this.openSalesforceContent(data);
}
return true;
}
Expand Down Expand Up @@ -750,21 +750,38 @@ export class SalesforceIntegration {
}

/**
* Open a Salesforce view.
* Open salesforce content in a view or as an app.
* @param data The data to use for opening.
*/
private async openSalesforceView(data: SalesforceResultData): Promise<void> {
const preload = this._settings?.preload;
const viewOptions: OpenFin.PlatformViewCreationOptions = {
url: data.url,
fdc3InteropApi: "1.2",
interop: {
currentContextGroup: "green"
},
customData: { buttonLabel: "Process Participant" },
preloadScripts: [{ url: preload ?? "" }]
private async openSalesforceContent(data: SalesforceResultData): Promise<void> {
const interop: OpenFin.InteropConfig = {
currentContextGroup: "green"
};
await this._integrationHelpers?.launchView(viewOptions);
const customData = { buttonLabel: "Process Participant" };
const url = data.url;

if (this._settings?.appId && this._integrationHelpers?.launchApp) {
await this._integrationHelpers?.launchApp(this._settings.appId, {
options: {
type: "view",
view: {
url,
interop,
customData
}
}
});
} else {
const preload = this._settings?.preload;
const viewOptions: OpenFin.PlatformViewCreationOptions = {
url,
fdc3InteropApi: "1.2",
interop,
customData,
preloadScripts: [{ url: preload ?? "" }]
};
await this._integrationHelpers?.launchView(viewOptions);
}
}

/**
Expand Down
38 changes: 38 additions & 0 deletions how-to/integrate-with-salesforce/client/src/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ export interface SalesforceSettings {
*/
preload: string;

/**
* App Id. Should this integration launch an app instead of a view.
*/
appId?: string;

/**
* Map the data from SF to templates, if you just include the type field the default display will be used.
*/
Expand Down Expand Up @@ -378,6 +383,15 @@ export interface IntegrationHelpers {
* @returns The interop client.
*/
getInteropClient(): Promise<OpenFin.InteropClient | undefined>;

/**
* If available, this function lets you request the launch of an application that is available to this platform and
* the current user.
* @param appId The id of the application that is registered against the currently running platform
* @param launchPreference If the app supports launch preferences then these can be passed.
* @returns Nothing.
*/
launchApp?(appId: string, launchPreference?: UpdatableLaunchPreference): Promise<void>;
}

/**
Expand Down Expand Up @@ -491,3 +505,27 @@ export interface ThemeClient {
*/
getPalette(): Promise<CustomPaletteSet>;
}

/**
* Are there any preferences you would like to apply when launching this application?
*/
export interface UpdatableLaunchPreference {
/**
* Are there any app type specific options you would like to apply?
*/
options?: ViewLaunchOptions;
}

/**
* Additional options that apply to a view
*/
export interface ViewLaunchOptions {
/**
* View options type
*/
type: "view";
/**
* The option to override a few settings that are specific to views.
*/
view?: Partial<Pick<OpenFin.ViewOptions, "url" | "interop" | "customData">>;
}
Loading