Quantcast
Viewing all articles
Browse latest Browse all 3876

Using the broadcast messaging (BCM) client side API

The portal broadcast messaging feature is provided with an out-of-the-box sample UI.

Most customers would want to customize the UI to fit their framework page.

 

 

In order to allow this we have opened a client-side API that allows developers to create their own iView and interact with the BCM service.

 


Prerequisites:

  1. You have installed SAP NetWeaver Portal (EP) 7.31 SP11 or above.
    • You have created a delta link for the Broadcast Message Framework iView in your framework page and set it to visible.This iView is located under Portal ContentàPortal UsersàStandard Portal UsersàiViewsàBroadcast Messages
    • Image may be NSFW.
      Clik here to view.
      BroadcastMessageFramework.png
  2. You have enabled the BCM service by setting the BCM is active property to true.

                Image may be NSFW.
Clik here to view.
bcmService.png

 

The API

 

 

The client side API is under the object window.BCM.API and contains the following methods:

 

 

isPollingActive() - this method checks if the BCM polling mechanism is active. If the mechanism is not active, the broadcast messages will be taken from the server only once.

 

 

getPollingIntervalTime() - This method returns the number of minutes between each request to the server.

 

 

getActiveMessagesForCurrentUser(success callback function, fail callback function) - This method gets all of the user’s broadcast messages (according to the user’s roles and groups) and return them to the success callback function in a JSON format (if successful) or returns a JSON with the status "fail".

 

 

Each message in the JSON has the following attributes:

    • messageId - The message ID, which is a unique ID for the message in the server.
    • messageBody - The actual message body.
    • isRead - A boolean stating if this message has already been read by this specific user.
    • isPriority (added in SP12) - A boolean that indicates whether this message has a higher priority.

 

setMessageAsRead(message ID, callback function for status) - Sets the message state to "already read" for this user in the UCD.

The callback function will receive a JSON with a "success" or "fail" status.

 

 

Example:

 

window.BCM.API.getActiveMessagesForCurrentUser(onMessagesReceived, onNotMessagesReceived);

 

   function onMessagesReceived(messagesJSON){

    //check that the actual size of the messagesJSON is more than 0.

    if(messagesJSON.length > 0)

    {

     var newMessagesArrived = false;

     for(var i = 0; i < messagesJSON.length; i++)

     {

      createMessage(messagesJSON[i].messageId, messagesJSON[i].messageBody, messagesJSON[i].isRead, messagesJSON[i].isPriority);

      // check that this message was not already read and update the new messages flag.

      if(!messagesJSON[i].isRead)

      {

       newMessagesArrived = true;

      }

 

     }

    }

   }

 

------------------------------------------------------------------------------------------------------

 

       window.BCM.API.setMessageAsRead(messageId,function(data){

        // check if the operation has failed or succeeded.

        if(data.status !== "success"){

         if(window.console){

          window.console.log("couldn't set message: "+data.messageId+" as read");

         }

        }

        else{

         // if operation succeeded mark message as read in the user interface

         changeMessageBackground(messageId);

        }

       });

 

If you would like to learn more regarding the BCM API please ask for information in the comments and I will try to add it to the article.

 

Saar


Viewing all articles
Browse latest Browse all 3876

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>