Skip to Content
Technical Articles

Reusable Flows with Common Resources and Open Connectors

SAP Cloud Platform offers 3rd party connectivity called Open Connectors. There are 170+ Open Connectors that feature a harmonized, restful API. You can read all about them and more of their features here like eventing, maintaining a valid authorization token, and more.

One such feature is called Common Resources. They allow you to build reusable flows by extracting out the mapping that is unique to each customer from the flow template. Furthermore, with Common Resources, the Connector itself doesn’t have to be chosen until the end user sets up the flow. That’s right – the end user to attach any of the 170+ Open Connectors to the flow template without changing anything in the flow!

Let’s break down both of these concepts individually. But first, let’s define what a Common Resource is and how to make one using an SAP SuccessFactors Employee Central payload as an example.

 

Creating a Common Resource

A call to this URL: https://{{subdomain}}.successfactors.com:443/odata/v2/PerPersonal(personIdExternal=’109032′,startDate=datetime’1990-01-01T00:00:00′)

Returns this response in JSON (provided you have the Accept header is equal to application/json):

{
    "d": {
        "__metadata": {
            "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')",
            "type": "SFOData.PerPersonal"
        },
        "personIdExternal": "109032",
        "startDate": "/Date(631152000000)/",
        "lastName": "Мухина",
        "businessLastName": null,
        "lastModifiedDateTime": "/Date(1505721477000+0000)/",
        "gender": "F",
        "endDate": "/Date(253402214400000)/",
        "displayName": null,
        "createdDateTime": "/Date(1442370404000+0000)/",
        "title": null,
        "createdOn": "/Date(1442356004000)/",
        "businessFirstName": null,
        "attachmentId": null,
        "preferredName": null,
        "initials": "A",
        "lastModifiedBy": "lhradmin",
        "script": null,
        "lastModifiedOn": "/Date(1505707077000)/",
        "firstName": "Анастасия",
        "nationality": "RUS",
        "createdBy": "admindlr",
        "middleName": null,
        "nativePreferredLang": "10240",
        "salutation": "10809",
        "maritalStatus": "10825",
        "localNavAUS": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavAUS"
            }
        },
        "localNavESP": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavESP"
            }
        },
        "localNavUSA": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavUSA"
            }
        },
        "nativePreferredLangNav": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/nativePreferredLangNav"
            }
        },
        "maritalStatusNav": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/maritalStatusNav"
            }
        },
        "personNav": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/personNav"
            }
        },
        "localNavFIN": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavFIN"
            }
        },
        "localNavARE": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavARE"
            }
        },
        "localNavDEU": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavDEU"
            }
        },
        "localNavFRA": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavFRA"
            }
        },
        "localNavITA": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavITA"
            }
        },
        "localNavBRA": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavBRA"
            }
        },
        "localNavZAF": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavZAF"
            }
        },
        "titleNav": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/titleNav"
            }
        },
        "localNavQAT": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavQAT"
            }
        },
        "localNavSAU": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavSAU"
            }
        },
        "localNavNLD": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavNLD"
            }
        },
        "localNavCHE": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavCHE"
            }
        },
        "localNavDNK": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavDNK"
            }
        },
        "salutationNav": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/salutationNav"
            }
        },
        "localNavCHN": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavCHN"
            }
        },
        "wfRequestNav": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/wfRequestNav"
            }
        },
        "localNavGBR": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavGBR"
            }
        },
        "localNavPRT": {
            "__deferred": {
                "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/PerPersonal(personIdExternal='109032',startDate=datetime'1990-01-01T00:00:00')/localNavPRT"
            }
        }
    }
}

Next, in Open Connectors, we’ll create a Common Resource that matches this data model. That way, all you would have to do is post this payload to any Connector (Salesforce, ServiceNow, etc) as long as the Common Resource is mapped. A Common Resource, allows you to define the request and response payload instead of having to rely on the unique payload structure for each Connector – which is always different from Connector to Connector.

We can use this employee payload to create a Common Resource that exactly matches this structure by choosig Import JSON and copying the payload in the next screen.

Here is our newly created Common Resource named commonEmployee.

Now we can map this structure, which is the SAP SuccessFactor Employee payload structure to any of the Open Connectors. Let’s map it to the ServiceNow contact object:

The mapper will discover your unique fields, even your custom fields on the right hand side.

Click on that upper right cog and make sure these are checked:

And you’re done! You now have created a Common Resource and can POST, GET, etc to it just as you would a regular resource. POST /commonEmployee. Pictured below you will notice that the new common resource acts and behaves like any resource on the Connector Instance.

 

To recap – we can POST a contact to ServiceNow with the SuccessFactors employee payload (as seen above) – not the actual ServiceNow contact payload which looks like this (and is different from the Salesforce contact create payload, etc):

{
  "active": true,
  "building": "string",
  "calendar_integration": 0,
  "city": "string",
  "company": "string",
  "cost_center": "string",
  "country": "string",
  "date_format": "string",
  "default_perspective": "string",
  "department": "string",
  "email": "string",
  "employee_number": "string",
  "failed_attempts": "string",
  "first_name": "string",
  "gender": "string",
  "home_phone": "string",
  "internal_integration_user": true,
  "introduction": "string",
  "last_login": "string",
  "last_login_time": "2019-08-27T21:12:57.432Z",
  "last_name": "string",
  "ldap_server": "string",
  "location": "string",
  "locked_out": true,
  "manager": "string",
  "middle_name": "string",
  "mobile_phone": 0,
  "name": "string",
  "notification": "string",
  "password_needs_reset": true,
  "phone": 0,
  "photo": "string",
  "preferred_language": "string",
  "roles": "string",
  "schedule": "string",
  "source": "string",
  "state": "string",
  "street": "string",
  "sys_domain_path": "string",
  "sys_mod_count": 0,
  "sys_tags": "string",
  "time_format": "string",
  "time_zone": "string",
  "title": "string",
  "user_name": "string",
  "user_password": "string",
  "vip": true,
  "web_service_access_only": "string",
  "zip": 0
}

 

This enables us to make resusable flows, not point to point flows, which brings us to the next section:

Creating Reusable Flows with Common Resources

Here is an SAP Cloud Platform Integration flow that gets employee from SAP SuccessFactors and posts it to both Salesforce and ServiceNow using Common Resources:

 

I’m using this trigger in Postman:

https://p2xxxx8-iflmap.hcisbp.us3.hana.ondemand.com/http/ocn_cr_demo/109032 where 109032 is the employee ID in SuccessFactors.

This flow retrieves the employee from SuccessFactors and then posts that exact payload to two different Open Connectors – Salesforce and ServiceNow by posting the SuccessFactors payload, unaltered, to the same Common Resource.

Let’s contrast this to having mapped the SuccessFactors payload to the unique payloads for both Salesforce and ServiceNow. We’d have a flow that was really only good for one end user, and that was officially a point to point flow.

But it gets better.

Common Resources Allow the Connector Selection at a Later Time

Notice how in this flow it seems like you must use ServiceNow and Salesforce. Well, even that we can generalize. For example, when the end user is onboarded with this flow, he can make a credential for the Open Connector he wishes to use (could be any of the 170+ Connectors) and as long as it has an object that is mapped to the Common Resource /commonEmployees, it can be implemented in the flow by just switching out the credential. If you are going to use the Open Connector adapter credential, it would look like this:

Note that the flow pictured uses the standard HTTP adapter – in which case, the Authorization header in the previous step can be swapped out for your Conector Instance’s Authorization String (which has the format {Authorization: User xxx, Organization xxx, Element xxx}).

 

I hope you’ve enjoyed this journey of making a reusable flows using the amazing feature called Common Resources in SAP Cloud Platform Open Connectors. Happy Integrating!

 

 

Be the first to leave a comment
You must be Logged on to comment or reply to a post.