Skip to Content
Author's profile photo Jeroen van der A

How to save comments in Design Studio

In my session in the BI2016 in Vienna last week I encouraged everybody in the room to come to SCN. I promised that I would write an blog about comments to give a good reason to come here and join the community.

So this is to fulfill my promise. How to save comments in your application?

comment screen.jpg

Comment screen

In the example I showed an comment screen, with a save button. which added a comment component to the fragment gallery

/wp-content/uploads/2016/06/commnent_parts_982801.jpg

Comment in fragment gallery

And finally it was dragged in the selfmade dashboard.

/wp-content/uploads/2016/06/dashboard_including_982808.jpg

Comment added to dashboard

Using bookmarks

The trick is to use bookmarks. You can either use multiple input fields or you can have an SDK that works as an editor. The thing is that you set the text in an component. (in the first case use a formatted text component), bookmark the component.

You will be able to load the comments back again or add them into an split cell container. This allows users to add comments to their self-made dashboards.

When you save to enable users to add their own remarks. The following two lines suffice:


var newBookmark = Bookmark.PortableFragmentBookmark.saveBookmark("Comment_dashboard", PNL_COMMENT,"Dashboard Comment");
FRAGMENTGALLERY_1.addItem(newBookmark);
Where PNL_COMMENT is a formatted text component.
Basically you can create the content for the component with script like this :
var title = "<H2>" + INPUT_1.getValue() + "</H2>";
var content = "<p>" + INPUT_2.getValue()+ "</p>";
FORMATTEDTEXTVIEW_1.setHtmlText(title+content);

Using title as unique key

The next step is to have context related bookmarks. We want comments that apply to the current view that you’re currently have.

Suppose that you look at data voor Store 2512 in month 01 2016. You want the comment on that particular subset to be shown.

To able to retrieve that we need to store a key in the bookmark. We will use the title property of the bookmark to store the unique key for the store and month.


Var currentMonth = “200601”
 var currentKey = “2512”

Bookmark.PortableFragmentBookmark.saveBookmark(currentStore+currentMonth, PNL_COMMENT,"Dashboard Comment");

Colllecting later on can be done with script code similar to this


var myBookmarks = Bookmark.PortableFragmentBookmark.getAllBookmarkInfos("Dashboard Comment ");

myBookmarks.forEach(function(element, index) {
if (element.title == currentStore+currentMonth)
{
LIST_BOOKMARKS.addItem(element.id, element.title);
}
});

In this case only comments for this particular store+month are loaded into a listbox. Note you could have multiple comments as this is not a truly unique key field.

Final thing

You may have noticed that I use a fancy editor in my example. Actually this is a SAPUI5 element. The underlying code is quite simple to add it :


jQuery.sap.require("sap.ui.richtexteditor.RichTextEditor");
sap.ui.richtexteditor.RichTextEditor.extend("com.rabobank.sapui5.RichTextEditor", {
                initDesignStudio: function() {
                                var that = this;
                                var _currentValue = undefined;
                                this.attachReady(function(oControlEvent)
                                                                {this.fireDesignStudioEvent("onInit");});
                                this.attachChange(function(oData)
                                                                {
                                                                                this.fireDesignStudioPropertiesChanged(["value"]);
                                                                                this.fireDesignStudioEvent("onChange");
                                                                });
                },
                renderer: {
                                }
});

And that’s it . A fairly easy workaround to have some comment functionality in your application. I hope you can find some use in your own applications.

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Jeroen,

      Thanks very much. Your post has been very helpful, I am giving fragment bookmarks a title of YearMonth ('yyyymm') when saving but was not sure how to locate the bookmark id to load the appropriate bookmark for the relevant YearMonth. (i.e. I don't want the user to have to select the bookmark from a selector that passes the id)

      //GET THE CURRENT DATE (OR THIS  COULD BE A VALUED SELECTED BY //USER)

      var DateToday =  APPLICATION.getInfo().dateNowInternalFormat;

      var YearMonth = Convert.subString(DateToday, 0,6);

      //GET THE ARRAY OF ALL BOOKMARKS

      var array = Bookmark.FragmentBookmark.getAllBookmarkInfos();

      //GET THE BOOKMARK ID FOR THE RELEVANT  SELECTED YEARMONTH FROM //THE BOOKMARK ARRAY

      var current_value = "";

      array.forEach(function(element, index) {

      if(element.title == YearMonth) //based on the year & month get the id

      {current_value = element.id;} //get the bookmark id

      });

      //LOAD THE BOOKMARK FOR THE SELECTED YEAR MONTH THIS MUST BE ID //NOT TITLE

      Bookmark.FragmentBookmark.loadBookmark(current_value);

      Now have behind the scenes control over monthly comments! Thanks for the post.

      Author's profile photo Jeroen van der A
      Jeroen van der A
      Blog Post Author

      thanks for the nice reply

      best regards,

      Jeroen

      Author's profile photo Carsten Schild
      Carsten Schild

      Thanks for the post - helped a lot.

      It seems this approach is user dependend.

      Is it possible to make the comments visible to other users(especially on Netweaver)?

       

      Author's profile photo Former Member
      Former Member

      It will help you in strengthening the weak area of your oracle database 12c installation and administration 1z0-062 pdf.

      Author's profile photo Alex Polyakov
      Alex Polyakov

      Hi Jeroen,

      Could you please explain how to add sapui5 richtext editor to Design Studio? This funky editor is really needed.

       

      Thank you,

      Alex

      Author's profile photo Former Member
      Former Member

      Yes here i want to tell you i have the same problem and i did’t get the solution yet Online But after read this now i am feeling i have found solution of my problem .

      Author's profile photo Swapnil Kulkarni
      Swapnil Kulkarni

      Hi Jeroen,

      Can you please provide some details on how to add this Rich Text Editor in SAP Design Studio?

      I got bit confused with below code. Where am I suppose to put it?

      jQuery.sap.require("sap.ui.richtexteditor.RichTextEditor"); sap.ui.richtexteditor.RichTextEditor.extend("com.rabobank.sapui5.RichTextEditor", { initDesignStudio: function() { var that = this; var _currentValue = undefined; this.attachReady(function(oControlEvent) {this.fireDesignStudioEvent("onInit");}); this.attachChange(function(oData) { this.fireDesignStudioPropertiesChanged(["value"]); this.fireDesignStudioEvent("onChange"); }); }, renderer: { } });

      Author's profile photo Anna Shetty
      Anna Shetty

      Thanks for this wonderful article and continue sharing more topics like this.