web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

Object Object Error

(0) ShareShare
ReportReport
Posted on by 8

Dear Reader,

 

I am getting error "Object Object" while running below query inside browser java script

 

var scroller = document.getElementById('scroller');

// Get the scrollTop, clientHeight, and scrollHeight values
var scrollTop = scroller.scrollTop;
var clientHeight = scroller.clientHeight;
var scrollHeight = scroller.scrollHeight;

if (scrollTop + clientHeight >= scrollHeight) {
  console.log('You have reached the end of the scroller!');
} else {
  console.log('You have not reached the end of the scroller yet.');
}

I have the same question (0)
  • eetuRobo Profile Picture
    4,579 Super User 2026 Season 1 on at

    That usually means an error. I would assume that the javascript is not finding the 'scroller' element. So it might return null and that is the cause of the [object Object] result.

  • Verified answer
    NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @mohamedjagrala !

     

    Try this.

     

    function ExecuteScript()
    {
    var scroller = document.getElementById('scroller');
    
    if (scroller) {
     // Get the scrollTop, clientHeight, and scrollHeight values
     var scrollTop = scroller.scrollTop;
     var clientHeight = scroller.clientHeight;
     var scrollHeight = scroller.scrollHeight;
    
     if (scrollTop + clientHeight >= scrollHeight) {
     return 'You have reached the end of the scroller!';
     } else {
     return 'You have not reached the end of the scroller yet.';
     }
    } else {
     return 'Scroller element not found.';
    }
    }

     

     

    Use return statements and not console.log in the "Run JavaScript function on webpage" action as it returns a variable.

     

    And please enclose your code within a function. It can be of any name like:

    function ExecuteScript()
    {
    }

     

    function CheckScroller()
    {
    }

     

     

    I have added another check. That is to check whether scroller element exists or not. If it exists, it will do that calculation condition: scrollTop + clientHeight >= scrollHeight and if not, print not reached end of the scroller. If it doesn't exist, print 'Scroller element not found.'

     

    You would be able to see the output of the action like given below:

    NathanAlvares24_0-1719317803777.png

     

     

    I hope this helps.

  • mohamedjagrala Profile Picture
    8 on at

    This is working when i am running inside browser console this issue is not realated to scroller someting else

     

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @mohamedjagrala !

     

    Have you tried out the modified script I provided?

     

    console.log will only work on the browser. It won't work in the "Run javascript on webpage" action.

     

    Hence I suggested to replace console.log() to return statement. As that action returns a value.

  • mohamedjagrala Profile Picture
    8 on at

    Dear @NathanAlvares24 ,

     

    Sorry for ignore your previous post.

     

    After your suggestion its worked well.

     

    Thanks for help

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 248 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 204

#3
Haque Profile Picture

Haque 179

Last 30 days Overall leaderboard