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 / Run JavaScript functio...
Power Automate
Unanswered

Run JavaScript function on web page not working

(1) ShareShare
ReportReport
Posted on by 4

Hello, I´m trying to change a date on a website, the problem is that the date can only be changed by selecting it in a calendar that pops up. I think I could do it with PAD actions but would be really hard.

Another way that I found is to change the value with Javascript, so I tried to do it in the console, this is the code:

document.getElementsByName('fecha')[0].value = '27/03/2024'

That works, but when I try to use the Run JavaScript function on web page the flow runs but does nothing.

I´m using Chrome and when the action runs the browser says that it started debugging.

I have also tried just extracting data from the webside with the action (following all the tutorials that you can find) and I´ve gotten the same result, it runs fine but it will not extract the data and also the return variable will always be [Object object]

 

GFenzo_0-1711636108398.png

 

 

Thanks for the help in advance!

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

    I tried to replicate and got it to work in a testing site(https://demo.automationtesting.in/Datepicker.html) like this:
    Took the element I wanted to populate in chrome by 'Inspect' 

    eetuRobo_0-1711636924357.png


    Copy JS path in that field you want to populate:

    eetuRobo_1-1711636975130.png

    Then paste it into Run JavaScript and then like you have add .value = '27.03.2024' at the end

    eetuRobo_2-1711637051485.png

     

    Hope this helps

  • GFenzo Profile Picture
    4 on at

    Thanks for your suggestion, I've tried it but it doesn't work, again if I try to use the copied JS Path adding the .value on the Chrome console it works like a charm.

    But if I use the same code in the Run JavaScript action it will not work, again, chrome says that power automate started debugging so I think it's doing something, but it doesn't change the date.

     

    Thanks!

  • eetuRobo Profile Picture
    4,583 Super User 2026 Season 2 on at

    What if you use .focus() on the element in the javaScript? Does it focus on it? 

    eetuRobo_0-1711638751327.png

    Does the Result variable return something. For me it returns just [object Object] so might not be helpful at all

    eetuRobo_1-1711638796493.png

     

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @GFenzo 

    I recommend checking if basic alerts are functioning in your browser. It's also important to verify if there are any restrictions imposed by any security or browser settings that could potentially hinder your access.

     

    Are you attempting to execute this script from your local machine Power automate desktop to remote/VM machine?

     

    Deenuji_1-1711640763991.png


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏

     

    Deenuji_0-1711640718614.png

     

  • GFenzo Profile Picture
    4 on at

    I did try to add the .focus and it works (it highlights the box with the date)...

    Also I tried with Alert as @Deenuji suggested and it also works, it's just weird that it does not change the date maybe there's some kind of security that does not let me change it.

  • ejmvar Profile Picture
    4 on at

    Cannot verify JS in Browser at all.
    Nothing seems to work.
    - no alert("anything");

    - no focus on fields

    - no return (return"W";)

    Does it need anything to get able to run JS?
    I'm using Chrome.
    JS on the console works fine.
    TIA

     

  • ejmvar Profile Picture
    4 on at

    Found JS does not always execute if browser exists and I attach to it.

    Even if JS shows an alert, it fails to assign a value to an element in DOM.
    As an example:
    document.querySelectorAll(".datepicker-textbox")[0].value=Start_Date
    This fails from PAD, but works once tested in Chrome console.

     

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 247 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 164 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 138 Super User 2026 Season 2

Last 30 days Overall leaderboard