cancel
Showing results for 
Search instead for 
Did you mean: 

Write Widget names to a text box

JBARLOW
Contributor

Hi all,

In the same vein as this question:
https://answers.sap.com/questions/13572142/within-script-access-widgets-dynamically.html

How would I populate a text array with the names (ID's) of widgets?
The aim being to then add the array values to a text box in an app (this bit I think I can do)

Scenario
I have 4 charts in my app: Chart_1, Chart_2, Chart_3, Chart_4

Using the code below I can write the Chart names to the console

var WIDGETS = Application.getWidgets({type:WidgetType.Chart});
console.log(WIDGETS);

The output looks like this - i'm just not sure how to extract the id value and write that to an array 😞

Any ideas much appreciated,

Thanks

View Entire Topic
johnfeigs
Explorer
0 Kudos

Thank you SJohnson for the code!
some remarks for beginners:
1. one may rename the files to getWidgetName.js and getWidgetName.json

2. one needs to change the URL in the JSON file to "url": "/getWidgetName.js"

johnfeigs_0-1714807167655.png

2. one needs to zip the files to upload them correctly (i attached a zip which I manually changed into a .txt, maybe that works ... otherwise one can copy paste the code out of the code preview from your post since i had trouble downloading your txt files)