I am trying to get rowCount of a HTML table using Javascript. The code works fine in console. but it is not saving the value to power automate. The code is below:
function countTableRows() {
var tbody = document.getElementById('MainTable1512446');
if (!tbody) {
console.log('tbody element not found.');
return 0;
}
var rows = tbody.getElementsByTagName('tr');
var rowCount = rows.length;
console.log('Number of rows:', rowCount);
return rowCount;
}
countTableRows();
The error is thrown when the output is converting to a number and used as a loopindex. i added a display message for debugging it shows blank. What could be the solution?