• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
        • Localhost Action Invoker Namespace
        • Localhost.mapActionResult Action
        • Localhost.mapFile Action
        • Localhost.mapSymbol Action
        • Localhost.mapText Action
      • Logic Namespace
      • Message Namespace
      • Path Namespace
      • Settings Namespace
      • Sqlite Namespace
      • System Namespace
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Localhost.mapActionResult Action

Format
s = CS.Localhost.mapActionResult(action := ...ʃ, arguments := ...ʅ)
ArgumentDescriptionTypes / Required
actionThe name of the action to execute.string
required
argumentsArguments for the action.object
not required
Description
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.
Return Value
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.
Exceptions
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.
Example (HTML + JavaScript)
<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>
See also: Localhost Action Invoker Namespace, Localhost URL, execute Action