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 / 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

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard