• <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
        • CSPro Logic
        • OnActionInvokerResult Global Function
        • JavaScript (Embedded)
        • JavaScript (From Web Views)
        • JSON
        • Android Intent
      • Security 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
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

OnActionInvokerResult Global Function

Format
function string OnActionInvokerResult(string action, string result, string resultType)
Description
OnActionInvokerResult is a special global function. It is called when processing a result from the Action Invoker when called from CSPro logic. As with other user-defined functions, it must be defined in the PROC GLOBAL section.
The function must return a string value and have three string parameters. When the Action Invoker finishes processing an action, or the action ends in an exception, OnActionInvokerResult is called with the following arguments:
  • action: The name of the executed action.
  • result: The result of the action in JSON, or the exception message as a string.
  • resultType: The result type: undefined, null, string, number, boolean, array, object, or exception.
Return Value
If the function returns a blank string, "", the result of the action, or the exception, is processed as it normally would be. However, if a non-blank string is returned, that string is returned as the action result. When an exception is processed, if a non-blank string is returned, CSPro will not display the runtime error message.
Example
PROC GLOBAL

numeric aiSuccess;
string aiErrorMessage;

function string OnActionInvokerResult(string action, string result, string resultType)

   
// instead of displaying exception messages, set aiSuccess to true on success,
    // and on failure, store the error message in aiErrorMessage
    if resultType = "exception" then
        aiSuccess = 
false;
        aiErrorMessage = result;

       
// returning non-blank prevents CSPro from displaying the exception message
        exit " ";

   
else
        aiSuccess = 
true;
        aiErrorMessage = 
"";

       
// returning blank maintains the original result
        exit "";

   
endif;

end;

PROC EXAMPLE

   
CS.File.copy(source := "Rusty Blackbird.jpg", destination := "Vulnerable Birds/");

   
if aiSuccess then
       
errmsg("File copied successfully.");
   
else
       
errmsg("File copy error: %s", aiErrorMessage);
   
endif;
See also: Action Invoker Execution from CSPro Logic, User-Defined Functions, Function Statement