---
schema_version: "1"
id: 85ff87157bd6221f076e9e497de9f01b22eebb0178145cd4a877b3f09ef50510
title: Create a Connection Object in OmniOut (Managed Package)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_create_a_connection_object_in_omniout.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_connection_object_in_omniout.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 20d87dd0b2f2a5d7f6d436a6d59b662c3328dd70c60f9c641136590bf3eb44ce
description: 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.
products:
  - Omnistudio
release: "264"
---
# Create a Connection Object in OmniOut (Managed Package)

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.

![Managed Package app icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/resources-global/_corporate/images/managedpackageicon.png) This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see [Omnistudio Help](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&language=en_US).

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)](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_connection_object_in_omniout_for_flexcards.htm&release=264.0.0&type=5 "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.").

The templates on this page are examples that developers can use for reference material when building a connection.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/images/icon_note.png)

Note

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)](https://help.salesforce.com/s/articleView?id=xcloud.os_move_omniout_into_your_app.htm&release=264.0.0&type=5 "For the managed package runtime, generate a compiled dist folder to move OmniOut into your app project before deploying your app to a content management system.").

1. 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();
          }
        });
    ```
2. 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);
          }
        }
    ```
3. Configure additional connection options outside of OmniOut.