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:

console.debug('check data %o', data);

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


Paul

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);
            console.log($scope.selections.temp);
            });

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’.

Brian

Hi @bknott,

Great! Thanks! Much appreciated.


Paul

$tm1Ui.dimensionElements

can also return attributes.