Argument | Description | Types / Required |
action | The name of the action to execute. | string
required |
arguments | Arguments for the action. | object
not required |
The
Localhost.mapActionResult action executes another action with the action name specified as a string argument
action. The result of the action is mapped as a
localhost URL that provides access to the other action's result when accessed from a local web server. Action names are specified without the prefix
"CS.", e.g.,
"Clipboard.getText" for
Clipboard.getText. If the action to be called requires arguments, they can be forwarded to the action using
arguments.
This action is primarily for advanced uses, such as passing data to a
web view that may be too large to pass directly using an action such as
UI.postWebMessage.
A related action,
execute, executes an action and directly returns the result.
The action returns a string containing the localhost URL that can be used to access the result of the other action executed. The URL is valid as long as the CSPro application is running. If the other action returns undefined, the local web server will respond with a
404 error when accessing the URL.
The action throws an exception if any of its arguments are not specified in a valid form, if the action name is not valid, or if the other action executed throws an exception.
<script>
const CS = new CSProActionInvoker();
// get the directory listing for the application directory, mapping the result as a URL
const directoryListingUrl = CS.Localhost.mapActionResult({
action: "Path.getDirectoryListing",
arguments: {
path: ".",
recursive: true,
detailed: true
}
});
// request the result of the directory listing using the URL
const request = new XMLHttpRequest();
request.open("GET", directoryListingUrl, true);
request.onload = () => {
if( request.status >= 200 && request.status < 400 ) {
const directoryListing = JSON.parse(request.responseText);
// do something with directoryListing
}
};
request.send();
</script>