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 Platform Community / Forums / Power Automate / Java Script returning ...
Power Automate
Answered

Java Script returning values with [object Object]

(0) ShareShare
ReportReport
Posted on by 9

Sorry if this question has been asked before as I dont seem to find the answer.

Wanting to get the sessionID from the url - I created the following Java Script to get the sessionID but only to find out values returning is [object Object].  I have ran the function using the Console on devtools and the values look alright to me.

 

Any idea?  Is it formatting issues?

 

 

objectobject.PNG
objectobject2.PNG
I have the same question (0)
  • waynewalls Profile Picture
    74 on at

    Here's two suggestions...

     

    Try returning match[0] instead of match[1].  There is probably only one sessionID which, I think, should end up in match[0] and not match[1].  The returned value of [object Object] may be due to the fact that match[1] is null.

     

    If that does not work you could try using the "Get Details Of Web Page" action to return the current URL.  Then use PAD's Text actions to extract the sessionID from the returned URL.  This would keep the text processing within PAD and might be easier to debug.

     

    I'll be curious to know what happens.

     

    -- Wayne

  • Verified answer
    SushiSashimi11 Profile Picture
    9 on at

    Thanks @waynewalls 

    JavaScript didnt work well when returning a value.  I have tried with array [0] and it's still the same thing.  

    I have switched to manipulate the string within PAD itself and it works wonderfully.

  • rzaneti Profile Picture
    4,483 Super User 2026 Season 1 on at

    Hey everyone,

     

    I just ran with the same issue. According to PAD docs, the 'Run JavaScript function on webpage' will return a string (Text value) necessarily. Source: https://learn.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/webautomation

     

    rzaneti_0-1692744787871.png

     

    You can transform JSON objects into strings (and, with this, allow PAD to return it form this action) by using this code: JSON.Stringfy([your_object])

     

    In my case, I was trying to return some HTML elements caught through document.getElementById(), which returns an object (but not a JSON one). The workaround that I found was to get the parent element and use the 'innerHTML' property to access a string of the whole HTML code inside it.

     

    For example, if I want to return the 'target div' below as string, I would need to access its 'parent div':

    <div id="parent">
    
    <div id="target">
    <p><span>123</span > text text <i>abc</i></p>
    
    <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    </ul>
    
    </div>
    
    </div>

     

    To achieve it, we can use in JavaScript document.getElementById('target').innerHTML, which will return everything inside the div#parent (basically the div#target and children) as string. 

     

    Also, you can replicate this same logic for querySelector, or any other JavaScript methods to manipulate the DOM. 

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard