I am trying to create a tableau extension for which I need the username… can anyone help me how to extract the username dynamically from tableau to my extension can anyone help me with this solution
when i try to fetch the username it shows undefined..
const getSheetDataForUsername = (worksheets, index) => {
console.log(worksheets);
return new Promise(function (resolve, reject) {
const summaryOptions = {
maxRows: 0, // Max rows to return. Use 0 to return all rows
ignoreAliases: false,
ignoreSelection: false,
includeAllColumns: true,
summary: true,
tableauDataTranspose: true,
};
if (index < worksheets.length) {
// const sheetName = worksheets;
// const sheetName = worksheets[index].name;
const sheetName = worksheets[index].Worksheet;
console.log("Sheetname " + sheetName);
getSheetData(sheetName, summaryOptions, worksheets)
.then(function (sheetData) {
const dataRow = sheetData && sheetData.length ? sheetData[0] : {};
if (dataRow.hasOwnProperty("AsUser")) {
UserName = dataRow.AsUser;
console.log("Found AsUser wb -->: ", UserName);
setUsername(UserName);
resolve(UserName);
alert(username);
} else {
console.log("here");
resolve(getSheetDataForUsername(worksheets, ++index));
}
})
.catch(function (error) {
console.log("Error getting data for sheet: ", error);
resolve(UserName);
});
} else {
resolve(UserName);
}
});
};
`