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

Notifications

Announcements

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

I have the same question (0)
  • 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard