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 / JavaScript returning e...
Power Automate
Answered

JavaScript returning empty string

(0) ShareShare
ReportReport
Posted on by 2

Hello,

 

I am trying to get the URL to a file on a webpage using a JavaScript setp in Power Desktop Automate.

The URL is that of the icon show below :

 

DB922_1-1635246793598.png

 

To do so, I tried writing a JavaScript step as follows:

 

var dllink = window.location.origin + document.querySelector("#container > div > div > div.page.p-conso > div.table.table-facture > div > div:nth-child(1) > div:nth-child(3) > a").getAttribute("href");
WScript.echo(dllink);

 

Executing in the chrome console the variable, i.e. just :

window.location.origin + document.querySelector("#container > div > div > div.page.p-conso > div.table.table-facture > div > div:nth-child(1) > div:nth-child(3) > a").getAttribute("href")

 

Gives out the correct link.

 

However, when I try to display the %JavascriptOutput% in a message box, it comes out empty.

 

Would you have any idea why this JavaScript is not working in Power Desktop Automate while working in the Chrome console ?

 

I'd be very grateful if someone had a solution to my problem. Thank you in advance.

I have the same question (0)
  • Verified answer
    VJR Profile Picture
    7,635 on at

    Hi @DB922 

     

    Several members on the forum have been having this issue of javascript returning nothing. Not sure if its a bug in PAD.

    However, since its a webpage could you try spying that file icon element and see if it gives the url in the attributes section of the selectors. It should give. And then using a loop iterate through all the file icons on that page.

  • PP-Lover Profile Picture
    10 on at

    I have de same error and i see that no solution was found.

    Does anyone know something?

    Thanks

  • Miss_Girl Profile Picture
    8 on at

    I'm running into the same problem with both VBScript and Javascript.  I'm not using a webpage; I just tried basic Hello World stuff:

    Javascript:

    var strFile = "test";
    wScript.Echo(strFile);
    Console.Write(strFile);
    alert(strFile);
    return(strFile);

     

    VBscript:

    function test()
        print "Test1"
        WScript.Echo "Test2"
        return "Test3"
    end function

     

    in the vain hope that one of them would produce a result.  Is there some special format or special variable that the output has to come back with? 

  • VJR Profile Picture
    7,635 on at

    Hi @Miss_Girl 

     

    Please refer as below

     

    VBscript-

    VJR_0-1664334885226.png

     

    Run Javascript (not javascript on webpage)-

    VJR_1-1664335136190.png

     

    Hope this helps to use both the actions.

  • Miss_Girl Profile Picture
    8 on at

    Thank you VJR!

    It worked like a charm! 😉

    You're the greatest! 😊 

  • VJR Profile Picture
    7,635 on at

    😊

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
11manish Profile Picture

11manish 233

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 190

Last 30 days Overall leaderboard