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.
You can find more on the BCM here:
New Development: Broadcast Messages in SAP NetWeaver Portal
If you wish to use the BCM out of the box sample UI you will need to add it to your classic/afp framework page,
The application can be found under Portal Content >> com.sap.portal.broadcast.message.framework >> Sample_BroadcastMessageIview
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:
- You have installed SAP NetWeaver Portal (EP) 7.31 SP11 or above.
- You have enabled the BCM service by setting the BCM is active property to true.
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
Hi Saar
Thanks for sharing.
From what SP of Portal, this broadcast feature is given as out of the box?
Regards
Sandip
Hi Sandip,
The broadcast framework will be available as of 7.31 SP11.
The feature for indicating a higher priority message will be available as of SP12.
The feature is not available out of the box and you will have to add some iViews that are given since we did not want to force users to have those iViews in their framework pages
if they didn't want it.
But to configure this feature is really an easy task and takes no more then 2 minutes.
BR,
Saar
Hi Saar, great add-on!
Do you know if it's available on 7.4? We're on SP4.
Thanks in advance.
Best Regards,
Marcelo
Hi Marcelo,
It will be available 7.40 SP6 and the groups and priority features will be available in SP7.
BR,
Saar
Thanks!!
Best regards,
MFD
Hello,
I've added the iView Broadcast Message Framework to the AFP, but instead of the icon to the right of the welcome text , the iview is added below the greeting.
Can you help me?
Best regards,
Arnold
Hi Arnold,
The framework is just the iview that provides the API above.
In order for you not to see that blue/grey line, open the framework iview and set "show tray" to false.
Now in the content administration go to applications --> com.sap.portal.broadcast.framework --> right click on sample ui --> paste it in your desired folder and create a delta link to your framework page. (don't forget to also remove the tray).
Make sure you enabled the BCM in the NWA as shown above and it should work.
HTH,
Saar
Thank you Saar!
Now it works.
Regards,
Arnold
Great to hear,
BR.
Saar
Hello,
I have one more little problem.
I can't delete a message.
I got the following error message:
com.sap.tc.webdynpro.services.exceptions.CreationFailedException:
add of choice (label: Cancel) failed! (action: null)
at
com.sap.tc.webdynpro.clientserver.window.ConfirmationDialogDelegate.addChoice(ConfirmationDialogDelegate.java:198)
at
com.sap.tc.pp.ivs.bcm.wd.comp.bcmoverview.BCMOverViewView.onActionDelete(BCMOverViewView.java:386)
at
com.sap.tc.pp.ivs.bcm.wd.comp.bcmoverview.wdp.InternalBCMOverViewView.wdInvokeEventHandler(InternalBCMOverViewView.java:291)
at
com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:142)
at
com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:75)
...
88 more
We use NW 7.31 SP11.
Regards,
Arnold
Hi Arnold,
This issue requires some investigation, can you open a thread for this and I will try to help you?
Thanks,
Saar
Hi Saar,
should I started here a new tread or a discussion in SAP Enterprise Portal?
Sorry for my confusion.
Regards,
Arnold
Hi Arnold,
I meant open a new discussion in the Enterprise portal.
and please attach the traces so I can investigate them.
Thanks,
saar
Hi Saar,
I posted the error in the thread:
http://scn.sap.com/thread/3564484
Regards,
Arnold
Hi Saar,
I have followed all the above steps but still i cannot see the Broadcast icon in the portal.can you please suggest what else need to be checked.
KR,
Anil
Hi Saar
We are testing this feature on one 7.3 EHp1 SP12 Portal.
Creating a broadcast message is working but the issue is that although the message status is green (message is broacasting) the message icon is not being displayed on the right side.
The service properties are set as follows:
Message poling interval - 3 min
Polling state - true
BCM is active - true
Restarting the services didn't help.
Any idea what could be the cause?
Cheers
Marian
Hi Marian,
did you create a delta link of the broadcast framework and the broadcast sample UI to the framework page?
BR,
Saar
Hi Saar
Thanks for the hint. I've adapted the configuration and now it's working.
Cheers
Marian
Saar, Excellent post. Does broadcast messaging support translations?
Hi Trent,
Thanks for the feedback.
Broadcast messaging does support translations using the translation worklist.
BR,
Saar
Hi Saar,
in wich container of the AFP-Framework do I put the Example-IView. I put it in the Masthead-Container, but it wont disapear. When I debug the bcm_ui.js, I can see that logic.init() execute this line:
if (properties.isAjax){
welcomeTextElement = jQuery("#welcomeText");
}
but at this point in the HTML-Structure their does not exist a node with this ID. This came at some point later.
So how I get the script running, when the Desktop is renderd.
Thanks,
Thomas
Hi Thomas,
Is this a customized framework page? if not is it classic or AFP?
BR,
Saar
It is a customizing AFP. But the only thing we customized was the logo on the top left and we add another IView into the Hidden Technical Container.
By the Way, we use NW 7.31. Forget we need NW 7.31 for BCM 😛
Thanks,
Thomas
Hi Thomas,
Try to see if it works in the out of the box AFP as this sample UI was tailored for AFP and classic framework page and not for costumized framework pages.
Hi Thomas,
You are right, I have found something that was missing.
I will create a fix for it.
Thanks and BR,
Saar
Hello Saar,
where can I find the fix?
Thanks,
Thomas
Hi Saar,
Is there any kind of functionality where the contents/text of the Broadcast Message does not come from Portal, but comes from some other system outside of portal?
Thanks,
Tamal
Hi Tamal,
There isn't, the BCM only supports portal broadcast messages.
BR,
Saar
Hi Saar,
We are in EP 7.4 SP6.
I have enabled BCM service by setting the BCM is active property to true
But I dont find the iview under Portal Content >> Portal Users >> Standard Portal Users >> iViews >> Broadcast Messages
So I copied the Sample_BroadcastMessageIview from Portal applications --> com.sap.portal.broadcast.framework and added to my AJAX framework.
But now I dont find the role for broadcast manager. How to send messages.? Please Help
Hi Saar,
Thanks for sharing a nice blog and able to view the broadcast messaging. Is this possible to get the broadcasting icon on the left instead of right. I mean next to Favorites menu bar.
Best Regards,
Deep
Hi Deep,
The BCM UI is a sample UI, It is tailored for a specific place and a specific options.
So unfortunately it can't be customized in any way, not even in where it lies on the document.
The goal for the sample UI was to show the capabilities of the BCM.
Thanks and BR,
Saar
I have followed all the steps mentioned and I am able to create messgaes as well , but even after the time is reached the status is pending only.
Can you please suggest?
We hide the user name on the right hand side where it says "Welcome User", we found the name needs to show in order for the broadcast message icon to show. Can this be separated?
Also, any future capability to change bullhorn icon to something else?
Hi Saar,
I have followed all the steps mentioned in the blog but instead of the message it shows the iview name. Is there any other step to be done? I have raised thread as well for this issue.
http://scn.sap.com/thread/3776354
Regards,
Navya
Hi Navya,
Open the iView and set the property "show tray" to false.
This will remove the iView title, make sure that the iView sits in the masthead container.
BR,
Saar
Does bcm work with custom afp framework?
For a complete step by step guide, use Note 2558970 - Broadcast icon and messages are not displayed.