cancel
Showing results for 
Search instead for 
Did you mean: 

SAC Analytic Apps: Script to display all comments from a table Widget.

former_member40251
Participant

Hello SAC Experts!

I would like to know how to create a script to display a Text widget with all the comments based on the dimension filters of a table widget in an Analytic App.

For example, the Table displays Cost Centers + GL Accounts in the rows, and Version + Account Measure in columns.

For all the combinations of Cost Centers + GL Accounts displayed in the Table, I would like to have a widget to display the existing data point comments for that filters.

By now I could only display for 1 single dimension combination.

Kind regards

Mayumi

former_member821033
Discoverer
0 Kudos

Hi may24071978_ ,

I am working on similar use case and need to export all comments for given dimention filter. Did you find any solution for this ?

Regards,

Ayush

former_member40251
Participant
0 Kudos

Hi ayushkumar01 ,

Not yet. If I find the solution I will share here.

Kind regards

Mayumi

View Entire Topic
SimonKranig
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi may24071978_ ,

probably not best practice, but you could scrape the whole resultset of the table for comments:

1. i.e. get the resultset of the tables datasource and the DataSourceComments for this tables datasource as well.

2. loop over the resultset and for each entry build up a Selection

3. with this Selection you can query DataSourceComments (getAllComments).

4. Iterate over the CommentInfo to pick up the values you need into one string and add this result as e.g. 'CellComment ' to your current Selection from step 3.

		for (var j = 0; j < myCellComments.length; j++ ){
			myCurrentSelection['CellComment ' + j.toString()] = 
			'{commentId:' + myCellComments[j].commentId + 
			', createdAt:' + myCellComments[j].createdAt +
			', createdBy:' + myCellComments[j].createdBy.id +
			', numberOfLikes:' + myCellComments[j].numberOfLikes.toString() +
			', text:' + myCellComments[j].text	+ '}';

...

With that you should have the dimension values and respective comments in one data structure with which you can fill a text field.

best regards,

Simon

adrweb
Discoverer
0 Kudos

Can you tell me how to convert a ResultSet to a Section ?

SimonKranig
Product and Topic Expert
Product and Topic Expert
0 Kudos

adrweb

Selections:

https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#Selection

In short: iterate over the resultset and for each entry in it, retrieve the dimension id and its value id and add it to a selection.

-> { dim1 : idvalue of dim1, dim2 : idvalue of dim2, .....}

you can initialize a selection variable like this (adding Version by default to it, which will get its value assigned in the loop through the resultset)

var myCurrentSelection = cast(Type.Selection, {'Version':''});

Simon