Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
The Comments Technical Component allows users to create and view comments in Lumira documents/applications. Comments can be shared across all applications within a Lumira document. Note that comments are supported on SAP Lumira Documents Mode (.lumx file) and Legacy Mode (.biapp file within a .zip file) but not on Lumira Discovery.

To avail of this functionality, you must add the Comments technical component to the Outline view of the design tool. When the Comments technical component is added to the design tool, the scripting methods associated with the comments functionality will be available in the script editor.

There is a very helpful template available by default in SAP Lumira Designer which contains a very comprehensive comments dialog. Just create a new document in SAP Lumira Documents Mode and select Samples – Feature Samples.



There we can see SAMPLE_APPLICATION_COMPOSITE_COMMENTS_DIALOG together with the COMMENTS_DIALOG composite.


Comments Context Types


Comments can be created with an associated context (CommentContextType):



  1. NONE. The comment has no context. This is default when creating a comment with no context specified. This value is useful if you want to get all the comments without a specific context type.

  2. CONTEXT. This allows the user to specify a custom context to which the comment can be associated. The context can be anything, it’s like an ad-hoc type.
    A very common use of this context type is to apply it in the current filters of a data source.

  3. DATA. Comment applies to a data cell. This is default when creating a comment with a context. The comment icon will be visible depending on the navigation state.

  4. DIMENSION. Comment applies to a dimension. The comment icon will be visible as far as the dimension is visible.

  5. MEMBER. Comment applies to a member. The comment icon will be visible as far as the member is visible.


DATA, DIMENSION and MEMBER comments are the only ones which can be seen in a crosstab. In order for a comment to be visible in a crosstab datacell the navigation state is important. This is better explained in the section 'Create Comments on a Crosstab'.

Also note that in an SAP Document, the lumx file may contain comments from all the composites. Composites don’t have self-contained comments, they’re all part of the same lumx document.

A composite in one lumx document can be used across many applications in other lumx documents. So a composite can be used in applications from different lumx documents but the “owner” of the comment is the document where the application is in.

Create Comments


Create a basic comment for the dashboard:
var commentId = COMMENTS.create("See my comment here");

Create a comment with the application name as context for the application:
COMMENTS.create(“See my comment here”),
{
"contextType": CommentContextType.CONTEXT,
"context": "{appname: " + APPLICATION.getInfo().name + "}"
}
);

Application comment with other properties:
var commentId = COMMENTS.create("See my comment here and properties", {
"context": {"sales":"2017"},
"contextType": CommentContextType.CONTEXT,
"isPublic": true,
"dataSource": DS_1
});

We can even add a context menu in order to create comments on the data cell of a crosstab:



When creating a new comment the output of the API method is the comment’s ID. If we want to extract the comment’s properties we can get the comment as a whole object by doing the following:



Comments created on Local Mode will be stored in the Commentary Technical Component folder of Lumira within the configuration folder:
C:\Users\YOURUSER\LumiraDesigner-workspace\com.sap.ip.bi.zen\repository\__TECHNICAL_CONTENT\COMMENTARY

Comments created on BIP will be stored directly on the database.

See that we can see the properties of the commentary BIP application on CMC (Central Management Console):
Applications – BI Commentary Application – Properties

If we change the database we point to, a series of services need to be restarted for the changes to apply (APS, ConnectionServers, LumiraServer). If the restarting is not performed, we might get an Analysis Application error when launching our Lumira report with the Comments component.

We should also be able to see the Commentary Service in the APS when selecting Edit Common Services.

Create Comments on a Crosstab


This is the most common use case for comments in Lumira: creating comments on a crosstab (datacell, dimension or member).

When creating comments on a crosstab we need to remember that dimension and member comments should stay visible as far as those dimensions and members are visible in the crosstab.

Bear in mind that background filters are only important when saving comments on data cells so the comment will show or not depending on the navigation state.



This means that if we create a comment on a datacell and then we apply a background filter through the Filter Members option, the previous comment won’t be shown on the cell since it’s considered as a different context. If we remove the filter, then the comment will show again.

Here we can see the scripting used to create DATA, DIMENSION or MEMBER comments on a crosstab, taking into account the background filters:
var selType = CONTEXT_MENU.getSelectionType() + "";  
// This will assign the type of context we selected: DATA, DIMENSION or MEMBER and convert it into a string
var sel = CONTEXT_MENU.getSelection();
if (selType == "DATA")
{ //add in the background filters
sel = DS_1.getBackgroundFilters(sel);
}
COMMENTS.create(selType + “Text of the comment”),
{
"context": sel,
"contextType": selType
}
);

Sometimes the datasource might have a background filter applied that we are not aware of. For this reason, it’s recommended to add the background filters every time we save a comment on a datacell. If not, our comment might be saved but not appear on the crosstab, which would result in confusion.

Update Comments


We can update an existing comment by using the API method setContent and providing its comment ID.

See an example here:
var commentId = COMMENTS_FEEDLIST_1.getSelectedItem().id;
COMMENTS.setContent(commentId,"Comment updated");

Show Comments


The most common method to display comments is through the Feed List component:
var FEEDLIST_1.setItems(COMMENTS.getComments());

If we want to show the content of a selected item on the feedlist:
var commentId = COMMENTS_FEEDLIST_1.getSelectedItem().id;
var commentObject = COMMENTS.getComment(commentId);

For a filtered list of comments:
var comments = COMMENTS.getComments
({
“context”: g_Context,
“contextType”: g_ContextType,
“dataSource”: DS_1,
“isPublic”: true,
“sortBy: CommentSortBy, CREATED_ON,
“order”: SortOrder.DESCENDING
});

Or if we want some more specific content and handling, see the following:
var comments = COMMENTS.getComments();
FEEDLIST_1.removeAllItems();

comments.forEach(function(element, index)
{
FEEDLIST_1.addItem({
"author": element.author,
"icon": element.icon,
"authorId": element.authorId,
"id": element.id,
"info": element.info,
"lastModifiedTime": element.lastModifiedTime,
"text": element.text
});

Crosstabs can display a red arrow icon if a comment is available for a data cell, a member or a dimension. You can enable the comment display within the crosstab via property ‘Comments Visible = true’.

On top of that, comments can be included in the output of the Export PDF if we select ‘Comments Visible = true’ in the PDF Technical Component.

New from Lumira 2.3!
Context properties 'context and context type' are exposed now


2 new properties on the comment object can be retrieved now:

  • context

  • context type




This will allow the end user to create comments with different contexts and then filter them so they can be rendered separately by context.

Saving a comment with a user defined context:
var commentId = COMMENTS.create(INPUTFIELD_1.getValue(), {
"context": {"sales":"2018", "country":"Ireland"},
"contextType": CommentContextType.CONTEXT,
"isPublic": true,
"dataSource": DS_1
});

Retrieving comments with the user defined context:
var comments = COMMENTS.getComments();

comments.forEach(function(element, index) {
var context = element.context;
context.forEach(function(value, key) {
if(value[0] == "Ireland") {
FEEDLIST_IRELAND.addItem(comments[index]);
}
});
});

Delete Comments


We can delete an existing comment by using the API method delete and providing its comment ID.

See an example here:
var commentId = COMMENTS_FEEDLIST_1.getSelectedItem().id;
COMMENTS.delete(commentId);

If we want to delete all the comments at once we can do:
var comments = COMMENTS.getComments();
comments.forEach(function(comment, index)
{
COMMENTS.delete(comment.id);
});

Public and Private Lumira Comments


All Lumira comments can be created as:

  • Public: everyone can view it. It may also be called Global.

  • Private: only the creator of the comment can view it. It may also be called Personal.


var publicCommentId = COMMENTS.create("Every Lumira user can see this comment", 
{
"isPublic": true
});

var privateCommentId = COMMENTS.create("Only the user that creates the comment can see it", 
{
"isPublic": false
});

This property is not linked to any rights on the platform since Public and Private comments are a ‘Lumira only’ concept.

If the Lumira user has the correct BIP rights, the user can add/edit/delete any comment on BIP via the BIP Commentary Service.

Don't leave without knowing


The commenting feature on Lumira is available from Lumira 2.1 onwards.

Comments are not supported on BIP 4.1 or lower. This is also the case for comments on Webi, Analysis Office, etc.

Also note that on BIP 4.2 SP0 - 4.2 SP4 the performance when saving/retrieving/deleting comments on Lumira is very slow whereas when using BIP 4.2 SP5 or higher the performance is very similar to the one we can experience in Local Mode.
See SAP Note 2566001 - Creating or listing Lumira 2.1 Comments on the BI Platform is taking longer than ...
53 Comments