• <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
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security, Resource Management, and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
      • Logic Namespace
      • Message Namespace
      • Path Namespace
      • Settings Namespace
      • Sqlite Namespace
      • System Namespace
      • UI Namespace
        • UI Action Invoker Namespace
        • UI.alert Action
        • UI.close Action
        • UI.enumerateWebViews Action
        • UI.getDisplayOptions Action
        • UI.getInputData Action
        • UI.getMaxDisplayDimensions Action
        • UI.postWebMessage Action
        • UI.setDisplayOptions Action
        • UI.setWebViewOptions Action
        • UI.showDialog Action
        • UI.view Action
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

UI.close Action

Format
s = CS.UI.close(ʃresult := ... ‖ exception := ...ʅ)
ArgumentDescriptionTypes / Required
resultThe result to return.string, number, boolean, array, object
not required
exceptionAn exception to throw.string, object
not required
Description
The UI.close action closes the current HTML dialog or web view.
Optional arguments allow you to pass information to the execution environment that launched the dialog or web view. A result can be provided, which serves as the return value for an action like UI.showDialog.
Alternatively, an invalid state can be signified by returning an exception, which will be thrown in the calling execution environment. This exception can be specified as a string containing the message text, or as an object in the format used by the throwException action.
This action has an impact in the following scenarios:
  • Displaying a HTML dialog using UI.showDialog (or htmldialog).
  • Display a web view using UI.view (or view).
  • Displaying HTML using CSCode or CSView.
Prior to CSPro 8.1, this action was named UI.closeDialog.
Return Value
The action returns a boolean value indicating if a dialog or web view successfully closed.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form.
Example 1 (HTML + JavaScript)
This example uses the asynchronous version of UI.close to ensure that the action does not block the current thread:
<script>
    const CS = new CSProActionInvoker();

    CS.UI.closeAsync({
        result: {
            userName: document.getElementById("userName").value,
            password: document.getElementById("password").value,
        }
    });
</script>
Example 2 (HTML + JavaScript)
This example returns an exception from one execution environment, JavaScript (run from web views):
<script>
    const CS = new CSProActionInvoker();

    // ...

    CS.UI.closeAsync({
        exception: "Could not validate token."
    });
</script>
This exception is then caught in another execution environment, JavaScript (embedded):
try {
    CS.UI.view({
        path: 
"validate-token.html",
        inputData: {
           
"provider": "...",
           
"token": "..."
        }
    });
}
catch(error) {
    CS.UI.alert({
        title: 
"Token Validation Error",
        text: error.message
    });
}
See also: UI Action Invoker Namespace, UI.showDialog Action, UI.view Action, throwException Action