Skip to Content
Author's profile photo Gaurav Loknath Gera

How to create HTML mashup for News in SAP Hybris Cloud for Customer

Mashups enable end users to combine and view data from the SAP Hybris Cloud for Customer and third party data sources and services. The framework tool, facilitate fast integration and innovative approaches that yield completely new functionalities.

HTML Mashup is used to embed HTML content in an iframe via URL protocol or HTML code.

A set of JavaScript APIs are provided to access the UI context (not only out port and extension fields but possibly the standard fields as well), call secure cross-domain RESTful web services (with basic authorization, OAuth or API keys),  and write data back to the UI in port or extension fields if needed.

In the following example, we’ll display the latest News for an Account’s. I am using Bing News Search API of Cognitive Toolkit. The API takes the search parameter, count of News items, Market from where the News is to be fetched and the safe search mode as inputs. Detailed documentation about the API is available in the below link.

  1. First, you need to get an API  key for Bing News Search.

You can get the key from the below site, create an account if you don’t have an account.

You can select Bing News from the list of APIs and generate API key for Bing News Search API, by clicking on the Create button. You will be asked to login.




The API keys will look like


2. You can use the below link to test the API’s of Cognitive toolkit.


3. Now, let’s create the HTML mashup in SAP Hybris C4C.

There are two types of HTML mashup – HTML code and URL mashup. You can either write your HTML code to render the data being fetched from the external application or you can also use the same interface as the external application by using the URL. In both the cases, the information is rendered in an iframe within the C4C TI.

We are going to use the HTML Code in our HTML mashup. The HTML code will call the above Bing News service API and render the result of the News search in an iframe on the Account screen.

HTML mashup can be created under Administrator –> Mashup Authoring. We are using the Silverlight client to create the HTML mashup, however we’ll test the mashup in the Fiori client.


Click on New –> HTML Mashup


4. Select the mashup category as Business & Finance and Port Binding as Additional Account Information.

Port Binding consists of different fields which can be passed parameters to the Mashup and these will then be mapped to the Mashup . Selection of the port binding would depend on the screen you want the mashup to be embedded in. The fields/parameters of the port binding are bound to the screen fields and the values are passed  on from the screen.


5. Select the HTML code and use the below code.


<!DOCTYPE html>
    <script src=""></script>
<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
            "q": sap.byd.ui.mashup.context.inport.AccountName,
            "count": "10",
            "offset": "0",
            "mkt": "en-us",
            "safeSearch": "Moderate",
            url: "" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","<API Key>");
            type: "GET",
            // Request body
            data: "{body}",
        .done(function(data) {
//            alert("success");
var temp;
for(var i=0;i<data.value.length;i++){
     temp+='<tr><td><p><a><div>'+data.value[i].category+'</div></a> <a><div>'+data.value[i].datePublished+'</div></a> <a href="'+data.value[i].url+'"><div>'+data.value[i].name+'</div></a> <a><div>'+data.value[i].description+'</div></a></p></td></tr>';
        .fail(function() {
<table id="items">

Couple of points to be noted:

  1. You can bind the AccountName parameter of the Input Parameter by select the parameter and clicking on the Copy button to the API parameter ‘q’.
  2. The API key need to be passed in the header of the request.

xhrObj.setRequestHeader(“Ocp-Apim-Subscription-Key”,”<API Key>”);


6. You can preview the result of the mashup by providing the input parameter, and click on the Preview button.


7. Lastly embed the News Mashup in the Accounts TI, by using the Key User Adaptation tool. You can use either HTML5 or the Silverlight client. Below screenshot is from the HTML5 client.



The end result looks like

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Barkath1 Shaik
      Barkath1 Shaik

      Hi Gaurav,


      Thanks for the informative blog. you mentioned that 'A set of JavaScript APIs are provided to access the UI context (not only out port and extension fields but possibly the standard fields as well)'.

      Can you point us to any documentation or sample code which allows us to do this. For example, if I prepare a mashup for the Quote object would I be able to call JavaScript API to get data from the standard fields or extension fields of the quote object. Currently the mashup only gets the standard outport from the Quote object which is the Quote ID. we had to use an embedded component in the middle to take the standard quote id outport from the Quote TI and have that as well as a extension field as a second outport from the embedded component and into the mashup. We are facing some issues in the same and hence having a JavaScript API which can access the standard and extension fields of the Quote object would definitely help to simplify the design.

      Request your help in pointing us to the correct documentation / sample code for the JavaScript APIs that you mentioned.



      Author's profile photo Mustafa Saglam
      Mustafa Saglam

      Hi Vipinkumar,

      You might find the following link useful -


      Author's profile photo Former Member
      Former Member

      Hello Gaurav and thanks for this amazing blog.

      Well i tried to do the same but i couldn't find the Additional Account Information port binding in the list of Port in mashup authoring.

      Is it a standard port binding or custom ?



      Author's profile photo Gaurav Loknath Gera
      Gaurav Loknath Gera
      Blog Post Author

      Hi Sarah,

      It's a standard port binding and available. You can also search for the port binding either by the name or a field within the port binding.



      Author's profile photo Former Member
      Former Member

      Hey ,

      Thanks for you're answer, i found it now.

      But the problem now is i cant find the mashup with port bidning that im adding in mashup authoring when a activate the adaptation mode i find just the mashups witout port binding but the one with port binding i cant find them