Run JavaScript Action(Power Automate Desktop)

08/10/2023

Japanese version.

This Action that executes arbitrary JavaScript. (Browser-independent)

This is effective for processing that would be difficult to handle with actions alone, but because it involves entering the program code itself, it is recommended that it be used only minimally in environments used by non-systems engineers.

However, complex conditional expressions are too large to be built with actions, so there are cases where code is more appropriate.

How to use

Drag "Run JavaScript" from "Scripting" under "Actions".

Set parameters.

Parameter

JavaScript to run

Specify the JavaScript code to be executed.

Power Automate Desktop variables are available in this (enclose the variable name in %).

Then, the basic form is to receive the results in JavaScriptOutput of Variables produced by WScript.StdOut.

JavaScript to run

In this example, the result is the Power Automate Desktop variable (NewVar) plus 5.

It is possible to read the value of a Power Automate Desktop variable.
However, it is not possible to set the value in reverse (a runtime error will occur).

In VB Script, msgbox could display the dialog, but alert in JavaScript did not work because of an error.
consoloe.log also had an error as well.

Variables produced as a result.

Variables produced

Stores the result of executing "JavaScript to run".

JavaScriptOutput

The results of JavaScript execution and standard output are stored.

The standard output is set when the code is specified as follows.

WScript.StdOut.Write(content);

This can be used to return calculation results to flow.

JavaScript to run
Variables produced as a result.

ScriptError

JavaScript error output (WScript.StdErr.Write), runtime errors and syntax errors are set.

WScript.StdErr.Write(content);
Code example.
Execution result of the code example.

In addition to the specified contents, runtime and syntax errors will be added.

For those who want to learn Power Automate Desktop effectively


The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.

Table of Contents.

Update History.

Links

Scripting Actions

Examples of Use

How to get the day of the week from a date.