Getting Element Attributes



Continuing the discussion from Canvas and D3 Charts:

Quick Summary on ways you get attributes of an element:

Hi @bknott,

Examine what is the content of the variable ‘data’ via:

Then from there, check the property that you would like to get. Take note too that it is case sensitive in JS.



OK. I have solved the issue but I’m posting the code to assist others. My issue was using value instead of Value. Case sensitive issue with JavaScript.

Here is the code designed to return the ‘Description’ attribute of an element.

$tm1Ui.attributeGet('MinePhysicals', 'measure_costing_schedules', $scope.selections.measure1, 'Description').then(function(data){
            $scope.selections.temp = data.Value; 
            console.debug('Returned by this function - %o', data);

This runs and I can dump the data object returned. See below

FormatString :"#,##0;(#,##0)"
FormattedValue: "Volume BCM"
HasDrillthrough :false
Ordinal :0
Status :"Data"
Value : "Volume BCM"
id :"d3154cdb-2708-93ed-ada8-72da5e406dbf"
isAnnotated  :false
isConsolidated :false
isReadOnly : false
odataId :"DZ1wZWgFAICMAAAg"
statusCode : 201

I also dump the $scope value to the console and it shows the data.Value or ‘Volume BCM’.



Hi @bknott,

Great! Thanks! Much appreciated.




can also return attributes.