Extending 'Upload Excel Files' Sample

Hi All

I’m trying to extend the Canvas Upload Excel Files sample.

I’ve copied the code and have a simple template uploading and displaying correctly. What I would like to do now is lookup from TM1 additional information per row based on the first column, to then be used in the saveItem function.

Below shows the canvas sample code in defining the record values:

var record = {
row: r - startRow + 1,
selected: true,
costCenter: costCenter,
m01: m01,
m02: m02,
m03: m03,
m04: m04,
m05: m05,
m06: m06,
m07: m07,
m08: m08,
m09: m09,
m10: m10,
m11: m11,
m12: m12,
error: error
};

Then I have added the following to return a value base on the cost center:

        $tm1Ui.cellGet('veolia','DIM Fin Cost Center',record.costCenter,'Final', 'Stream').then(function(data){
            record.division = data.Value;
            console.log(record.division);
        });

        $scope.lists.records.push(record);

The console log shows the division value being returned ok, however, the push statement does not include the new record.division value.

How can I get this new value included in the item that gets pushed to lists.record?

Thanks
David

Hi David,

The cellGet call is asynchronous so the $scope.lists.records.push(record) executes before the cellGet returns.

Hi @tryan

Thanks for your reply. Is there other any way then to get a cube/attribute value included in the lists.records array?

Thanks
David

Hi David,

Your current code will work, i.e. the division will be updated but it will happen in the future. You can add a counter or $watch $scope.lists.records so you know when all of the calls are complete.