You are here:
Create a Connection Object in OmniOut
Create a connection object to send and receive data with Salesforce. A connection object is required for all connection types, including proxies. The connection object exposes the instance URL, namespace, and request function.
If your OmniOut project has Omniscripts, create an event handler to pass the connection object after you get the omnioutcomponentready event.
Before You Begin
Add the OmniOut project to your application. See Move OmniOut to Your App.
To create a connection object, perform these tasks.
-
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.

