Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Retrieve all Data elements in custom code

wesleybrett1
Level 2
Level 2

Is it possible to return a full list of all data elements names in custom code (written under Rules)?

 

I have a few data elements and there will be new elements added in the future. I don't want to update my custom code every time a new element is added. Instead I want to GET a full list of data element names, then loop through the _satellite.getVar("<Data_element_name_here>") function in order to populate my query. 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
yuhuisg
Correct answer by
Community Advisor
Community Advisor

Yes, you can! They're actually available inside the_satellite object.

Object.keys(_satellite._container.dataElements)

View solution in original post

3 Replies
yuhuisg
Correct answer by
Community Advisor
Community Advisor

Yes, you can! They're actually available inside the_satellite object.

Object.keys(_satellite._container.dataElements)

View solution in original post

wesleybrett1
Level 2
Level 2
Perfect, thank you! Here's the start of my code encase anyone want to expand on it
wesleybrett1
Level 2
Level 2
for (let i = 0; i<Object.keys(_satellite._container.dataElements).length;i++) { let dataElementName = Object.keys(_satellite._container.dataElements)[i] console.log(dataElementName) }