SAP FSM (Field Service Management) shell is an extendable Web-Application. FSM shell host is the extendable part of the Web-Application and a FSM shell client is the extension. For more information regarding SAP FSM, check out the SAP Field Service Management Help Portal.
FSM-SHELL is a library which is designed to be used in FSM shell clients' applications to communicate with the shell host by using set of predefined events described below in API Documentation.
Minimal supported JavaScript version: ES5
- communication to host (ask for data from the host, see events section)
- receive data publish by the host
npm install
npm run build
-
Must be sent on application startup to get initial application context from the shell
-
Request payload
type: object
{ clientIdentifier: string; clientSecret: string; cloudStorageKeys?: CloudStorageKey[]; }
-
Response payload
type: object
{ authToken: string; cloudHost: string; account: string; accountId: string; company: string; companyId: string; selectedLocale: string; user: string; userId: string; userAccountFeatureFlagsEnabled: boolean; userAccountFeatureFlagsUserId: string; erpType: string; erpUserId: string; }
-
-
Request permissions for specified object from the shell
-
Request payload
type: PermissionRequest
{ objectName: string; owners?: string[]; }
-
Response payload
type: Permission
{ CREATE: boolean; READ: boolean; UPDATE: boolean; DELETE: boolean; UI_PERMISSIONS: number[]; }
-
-
Request settings value for specific key from the shell
-
Request payload
type: string
Key to read settings from -
Response payload
type: SettingsResponse<T>
settings value which was read from requested key{ key: string; value: T; }
-
-
Request value stored under specified key in cloud storage
-
Request payload
type: string
Key to read value from -
Response payload
type: GetItemResponse<T>
object containing key name and value which was read from requested key{ key: string; value: T; }
-
-
Save value in cloud staorage under specified key
-
Request payload
type: SetItemRequest<T>
object containing key name and value to store under that key{ key: string; value: T; }
-
Response payload
type: boolean flag indicating if value was saved successfully
-
-
trigger flow
-
Request payload
type: StartFlowRequest
object containing flow trigger id and initial context{ triggerId: string; initialContext?: [ { name: string; value: any; } ]; }
-
Response payload
type: void
-
-
Must be sent on application startup to get initial application context from the shell
-
Request payload
type: object
{ clientIdentifier: string; clientSecret: string; cloudStorageKeys?: CloudStorageKey[]; }
-
Response payload
type: object
{ authToken: string; cloudHost: string; account: string; accountId: string; company: string; companyId: string; selectedLocale: string; user: string; userId: string; initialContext: [ { name: string; type: string; value: any; } ]; screenConfiguration: Object | null; }
-
-
Used to indicate if current flow step ready to continue to the next step. Shell host will block switching to the next step until this event sent with true value in payload. If data at some point becames invalid again, this event with false value in payload can be sent in order to block switching to next step again.
-
Request payload
type: boolean
-
Response not needed
-
-
Will be sent from the shell host to flow app when user continue to the next flow step. Flow app should save(if needed) it's data, prepare output variables and send it in response to this event.
-
Request payload
type: void
-
Response payload
type: object
{ output: [ { name: string; value: any; } ] }
-
Will be emitted in response to any of request events in case if error occurs during handling the event.
- Payload Event to the shell host can be sent by using emit method from ShellSdk
this.shellSdk.emit(SHELL_EVENTS.Version1.REQUIRE_CONTEXT, { clientIdentifier: '<your-app-client-identifier>', clientSecret: '<your-app-client-secret>' });
type: string
string representation of the error object
-
import library and available events from fsm-shell package
import { ShellSdk, SHELL_EVENTS } from 'fsm-shell';
initialize the library
const shellSdk = ShellSdk.init(parent, origin);
where
- parent - reference to the parent window (window.parent) containing shell host application
- origin - origin for the shell host which loading your microfrontend
-
get the semantic version number of the shell library or the build timestamp.
console.log(ShellSdk.VERSION); console.log(ShellSdk.BUILD_TS);
-
event to the shell host should be sent by using emit method from ShellSdk
shellSdk.emit(SHELL_EVENTS.Version1.REQUIRE_CONTEXT, { clientIdentifier: '<your-app-client-identifier>', cleintSecret: '<your-app-client-secret>' });
-
to subscribe on shell host event on method from ShellSdk should be used
const handler = context => { // handle received context }; shellSdk.on(SHELL_EVENTS.Version1.REQUIRE_CONTEXT, handler);
-
to unsibscribe use off method from ShellSdk
shellSdk.off(SHELL_EVENTS.Version1.REQUIRE_CONTEXT, handler);
-
rxjs fromEventPattern method can be used to create reactive stream from events coming from the ShellSdk.
import { fromEventPattern } from 'rxjs'; ... const ctxStream$ = fromEventPattern<string>( handler => this.shellSdk.on(SHELL_EVENTS.Version1.REQUIRE_CONTEXT, handler), handler => this.shellSdk.off(SHELL_EVENTS.Version1.REQUIRE_CONTEXT, handler) ); ctxStream$.subscribe(context => { // handle received context });
-
In case you need further help, check out the SAP Field Service Management Help Portal or report and incident in SAP Support Portal with the component "CEC-SRV-FSM".
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.