Technology Blog Posts 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: 
florian_hamon
Product and Topic Expert
Product and Topic Expert
0 Kudos
734

In this blog, I will show you how to link a value in a graph with the generation of an eMail, passing through a parameter.

1 - Step one : Create your graph

In my example, I created a simple graph with an Employee name, and a value. In my example I am a middle-manager, that needs to make sure that all employees have fulfilled their mandatory trainings :

florian_hamon_0-1738333291812.png

The graph contains 1 dimension, 1 measure.

florian_hamon_1-1738333338751.png

2- Step two : Create a script

Now, clickon the 3 dots on the right hand corner of the graph : ...

Navigate to Edit Scripts > onSelect to open the script generation page.

In this page, you simply need to leverage the following code :

// Chart_42 is the name of the chart in the document
// %0A is the HTML for line break 

var selection = Chart_42.getSelections();
var email = "mailto:" + selection[0]["Employee_Name"] + "@bestrunbikes.com?subject=Please follow the mandatory trainings&body=You have overdue mandatory trainings. %0A Please do them as soon as possible. %0A Regards, %0A Top Management";
NavigationUtils.openUrl(email);

florian_hamon_2-1738333515963.png

First variable : selection, I retrieve the selected value of the graph (in my example my graph is called "Graph_42".

Then I create a variable called "email" that contains the html code to send an email. For more details on eMail HTML code, you can check this article : https://yoast.com/developer-blog/guide-mailto-links/

Once this is done, you need to PReview your document as scripting is not executed in Edit nor View mode

florian_hamon_3-1738334014046.png

If you want to have more great easy scripting hints, do not hesitate to follow Daniel Davis introduction to scripting : https://community.sap.com/t5/technology-blogs-by-sap/start-your-scripting-journey-the-easy-way-with-...