ash
ash

Reputation: 25

Displaying Power Automate Variable Text in Web Browser via JavaScript (Run JavaScript function on web page)

I am attempting to display a Power Automate Desktop variable's numeric value in a web browser instance using the Run JavaScript function on web page action in Power Automate Desktop (PAD). My PAD flow is as follows:

PAD user input via custom form --> Input value feeds into Excel model --> Excel model spits out output value --> Output value is read by PAD (ExcelData or model_output) --> PAD attempts to display model_output in a blank web browser page via JS function (Run JavaScript function on web page).

Here is my JS function:

function InjectOutput()
{
    var output = "%model_output%";
    document.querySelectorAll('document')[0].value=output;
}

This is the Microsoft help link I tried to use - https://learn.microsoft.com/en-us/power-automate/desktop-flows/how-to/populate-text-fields-click-links-javascript

Here is my entire PAD flow: enter image description here enter image description here

When running, my blank web browser page does not populate the value of model_output and I get a popup that reads "Microsoft Power Automate started debugging this browser."

Thanks for help with the JS function or otherwise.

Upvotes: 0

Views: 1332

Answers (1)

ash
ash

Reputation: 25

I was able to get this to work by switching to a simpler web page (blank.page) and modifying my code slightly based on selection of the appropriate Selector in the UI elements tab:


function InjectOutput()
{
    let output = "%model_output%";
    document.querySelector('textarea').value=output;
}

Upvotes: 0

Related Questions