For the managed package runtime, send and receive data to and from Salesforce by creating a connection object. A connection object must be present for every type of connection, including when a proxy is present. The connection object exposes the instance URL, namespace, and request function.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
If your OmniOut project has Omniscripts in it, you must create an event handler to pass the connection object after receiving OmniOut's omnioutcomponentready event. Follow the directions on this page.
If your OmniOut project has Flexcards only, use the initializeDatasourceSdk method to connect your app. See Create a Connection Object in OmniOut for Flexcards (Managed Package).
The templates on this page are examples that developers can use for reference material when building a connection.
The connection process is unique to each application and must be done outside the scope of OmniOut.
Before You Begin
Add the OmniOut project to your application. See Move OmniOut into Your App (Managed Package).
-
Create an event handler.
Example Event Handler
/** * Once the component is ready, an event is dispatched to let the DOM knows that a connection is expected. **/ document.addEventListener('omnioutcomponentready', evt => { if (evt.detail && evt.detail.omnioutcomponent) { evt.srcElement.connection = new YourOmniOutConnection(); } }); -
Create a connection object.
Example Connection Object
function BaseConnectionExample() { /** * Expose the request method **/ this.request = request; /** * @type {string} The namespace of the package **/ this.namespace = ''; /** * @type {string} The instance URL of your org **/ this.instanceUrl = ''; /** * A function that executes the HTTP requests. * @type {string} The target URL. * @type {Object} The data that is sent to the target URL. * @returns {Promise} A promise with the **/ function request(url, data) { return connection.requestPost(url, data); } } - Configure additional connection options outside of OmniOut.