Introducing Common Resources v2 Engine

By default, any new common resources (Common Resources) created in new user organizations across environments now utilize the Common Resource v2 engine.

This article explains some of the differences between the v1 and v2 engines, as well as how to specify which engine you want new Common Resources to use.

Why Common Resource V2 Matters

Common Resource V2 is the new backend for Sugar Integrate Common Resources. Most of the enhancements are user-facing, and upgrading should have no impact on the existing Common Resource API calls in any of your code. However, we do recommend that you follow the Recommended Actions to preserve availability in the future.

Common Resource V1 is not supported anymore, meaning we will not be adding new enhancements or resolving new defects for Common Resource V1. If you experience a bug with V1 we suggest you test with V2; if the issue persists, please submit a defect to product for further investigation. New Common Resource features such as Automapping or Common Resource Sharing will only be supported for Common Resource V2 users, so users will need to upgrade to take advantage of the latest and greatest enhancements. You can contact Customer Support for migrating your Common Resource engine from V1 to V2 or vice versa.

Differences between v1 and v2

New Data Structure

For Common Resources created using the v1 engine, the level property exists in the root level of the Common Resource object. However, for Common Resources created using the v2 engine, the level property is nested in the configuration parameter. Additionally, you now have access to a unique identifier fields[*].id for each field in your object.

Example v1 Structure

In this v1 example, level is at the root level and on the last line of the object:

{
  "id": 12345,
  "objectName": "songs",
  "fields": [
    {
      "type": "string",
      "path": "artists[*].name",
      "displayName": "artists"
    },
    {
      "type": "string",
      "path": "songName",
      "displayName": ""
    }
  ],
  "level": "organization"
}

Example v2 Structure

In this v2 example, level is nested under fields:

{
    "id": 12345,
    "objectName": "songs",
    "fields": [
      {
        "type": "string",
        "id": 11059,
        "path": "artists[*].name",
        "level": "organization",
        "displayName": "artists"
      },
      {
        "type": "string",
        "id": 11060,
        "path": "songName",
        "level": "organization",
        "displayName": ""
      }
}

New /VDRs APIs

The Common Resource v2 engine includes the new collection of  /VDRs APIs. A Postman collection for the API is available here (same link as earlier in this article), and will soon also be available via the API Docs in the UI.

Determining your Current Engine

If you do not know which engine your organization is utilizing for your newly built Common Resources, you can check by either through the UI or an API call. In addition, the selected version is managed independently between staging and production environments; changing the selected version in one environment does not automatically carry over to others.

Checking the Engine via UI

  1. Sign in to Sugar Integrate and click API Docs in the top-right corner.
  2. From the Platform API Documentation column on the left, click Organizations.
  3. Under the Organizations APIs list, click GET /organizations/me.
  4. Click Try it out, and then click Execute.
  5. In the response body, find the vdrVersion parameter. The value listed indicates the engine being used. 

Checking the Engine via API

  1. Make the following API call: https://api-us-staging.integrate.sugarapps.com/elements/api-v2/organizations/me
  2. In the response body, find the vdrVersion parameter. The value listed indicates the engine being used.

Backward Compatibility

When you upgrade to the V2 engine, all existing V1 APIs are backward compatible and no immediate code change is required to begin using and testing the V2 engine. 

The V1 APIs are deprecated and planned for retirement in 2021, so while no immediate code change is required, we recommended that you begin planning an upgrade. 

We suggest you run tests against your Common Resources in a staging environment prior to January 31, 2021. 

If you experience any issues with your Common Resources while testing in staging, please reach out to support or your Customer Account Manager.

Transformations via API

This section talks about mapping fields for transformations using APIs.

  1. Construct a JSON body as shown below. For descriptions of each parameter, see Transformation JSON Parameters. The below body will create a Common Resource with two fields, firstName and lastName. 
    {
     "fields": [
       {
         "type": "string",
         "path": "firstName",
         "displayName": ""
       }, {
         "type": "string",
         "path": "lastName",
         "displayName": ""
       
     ]
    }
  2. Call POST to /organizations/objects/{objectName}/definitions where objectName is the name of the Common Resource you want to create. You can do this via the API docs here or via a cURL command as shown below.
    curl -X POST "https://staging.cloud-elements.com/elements/api-v2/organizations/objects/VDRDocsTest/definitions" -H "accept: application/json" -H "Authorization: User {user_secret}, Organization {org_secret}" -H "Content-Type: application/json" -d "{ \"fields\": [ { \"type\": \"string\", \"path\": \"newName\", \"displayName\": \"\" }, { \"type\": \"string\", \"path\": \"logs\", \"displayName\": \"\" } ]}"
  3. Construct the JSON request body.
    • The id field in your response body (on the left) needs to be added as a new field for each field you created, called vdrFieldId, in your request body.
    • This is where you define your transformation, and state the path the VDR will map to on the vendor’s side, i.e. the value firstName in the path field, will map to the vendorPath field first_name. This is a transformation for Sugar CRM's /contacts (not /customers like in the image below) endpoint.
      Note: You can also add the level field to each field mapping, which will determine the level that your Common Resource fields will be mapped to. (See below where the firstName is mapped at the instance level while the field lastName is mapped at the account level.
      Request Body Response Body
  4. Call  POST to /organizations/objects/{objectName}/definitions where objectName is the name of your Common Resource (as defined in step 2) and keyOrId is the adapter key id . You can do this via the API docs in the UI (linked here), or via a curl command as shown below.
    curl -X POST "https://staging.cloud-elements.com/elements/api-v2/organizations/elements/234/transformations/VDRDocsTest" -H "accept: application/json" -H "Authorization: User {user_secret}, Organization {org_secret}" -H "Content-Type: application/json" -d "{ \"level\": \"organization\", \"vendorName\": \"customers\", \"fields\": [ { \"type\": \"string\", \"vdrFieldId\": 73519, \"path\": \"firstName\", \"level\": \"instance\", \"vendorPath\": \"first_name\", \"vendorType\": \"string\" }, { \"type\": \"string\", \"vdrFieldId\": 73520, \"path\": \"lastName\", \"level\": \"account\", \"vendorPath\": \"last_name\", \"vendorType\": \"string\" } ], \"configuration\": [ { \"type\": \"passThrough\", \"properties\": { \"fromVendor\": false, \"toVendor\": false } }, { \"type\": \"addToDocumentation\" }, { \"type\": \"inherit\" } ], \"isLegacy\": false}"
    
  5. Your Common Resource and transformation is now visible in the UI and available via API with the following cURL command (note you can also POST, PATCH, and DEL if your  Common Resource supports those request types).
    curl -X GET "https://staging.cloud-elements.com/elements/api-v2/VDRDocTest" -H "accept: application/json" -H "Authorization: User {user_secret}, Organization {org_secret}, Element {element_instance_token}"
    


Common Resource RBAC Matrix

The matrices below cover the privileges for Common Resource UI and Common Resource sharing. You can refer to this to understand how the new UI and sharing behaves for users with different roles and privileges.

VDR UI

Roles (Or) Privileges/ FeatureDefault Account + Organization AdministratorNon default account + Organization AdministratorAccount AdministratorOrganization
User
Default User
Create VDRXX
Delete VDRXX
Create Transformation
Delete Transformation
Add/Update/Delete Org Level FieldsXXX
Add/Update/Delete Account Level FieldsXX
Add/Update/Delete Instance Level Fields

Shared VDR

Roles (Or) Privileges/ FeatureDefault Account + Organization AdministratorNon default account + Organization AdministratorAccount AdministratorOrganization User

Default User
Share VDR
(Account owned VDR)
XXX
Unshare VDR
(Account owned VDR)
XXX
Delete VDR
(Account Owned VDR)
XXX
Delete Transformation
(Account owned Transformation)
XXX
Add/Update/Delete Org Level Fields

XXX
Add/Update/Delete Account Level FieldsХ
Χ
Add/Update/Delete Instance Level Fields