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 / Return object object, ...
Power Automate
Unanswered

Return object object, but its not null

(0) ShareShare
ReportReport
Posted on by 2

I have this code:

// Select all date elements that are not disabled
let availableDates = document.querySelectorAll('.calendar__date-container:not(.is-disabled) .calendar__date');

// Log or process the available dates
availableDates.forEach(date => {
console.log(date.textContent); // Replace with your processing logic
});

Which does work in console on edge, but if I try to put it in Power Automate Desktop, it just returns object object.

I have tried adding a new return line as the following:

return JSON.stringify(date.textContent);

But still the same. I can read that it might be because its an object, but can't get it to return the values..

btw, tried this https://masteringjs.io/tutorials/fundamentals/foreach-object, with some help from chatGPT, but still no luck, again it does seem to work in console.

let availableDates = document.querySelectorAll('.calendar__date-container:not(.is-disabled) .calendar__date');
let datesArray = [];

availableDates.forEach(date => {
datesArray.push(date.textContent);
});

return JSON.stringify(datesArray.join(', ')); // Replace with your processing logic

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    PAD can only return a single string as output from any scripts, and it only works with a return statement - the console.log command does not work, as it's not running in a console.

     

    So, if you want to return an array, you need to join it. No idea why you're using JSON.stringify() here, as it's not JSON. I'm pretty sure simply doing return datesArray.join(', '); should do the trick.

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Nokkkkk Profile Picture
    2 on at

    Thanks for your answer.
    JSON.stringify() was because I read that it might be able to convert what was in the array to a string. 
    Re: Fail to read an array returned from javascript... - Power Platform Community (microsoft.com)

    let availableDates = document.querySelectorAll('.calendar__date-container:not(.is-disabled) .calendar__date');
     let datesArray = [];
    
     availableDates.forEach(date => {
     datesArray.push(date.textContent);
     });
    
     return datesArray.join(', '); // Replace with your processing logic

    I tried this now, but still object Object. 

    This is the data in availableDates:
    CalendarDatesScreenshot.png

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Did you actually encapsulate your code into a function call like so:

    Function ExecuteScript() {
    let availableDates = document.querySelectorAll('.calendar__date-container:not(.is-disabled) .calendar__date');
     let datesArray = [];
    
     availableDates.forEach(date => {
     datesArray.push(date.textContent);
     });
    
     return datesArray.join(', '); 
    }

    This is required in the Run JavaScript function on web page action.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 426

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard