• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • Synchronization
    • 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
        • Data Action Invoker Namespace
        • Data.close Action
        • Data.contains Action
        • Data.countCases Action
        • Data.deleteCase Action
        • Data.getCurrentCase Action
        • Data.open Action
        • Data.query
        • Data.queryCases Action
        • Data.queryKeys Action
        • Data.readCase Action
        • Data.writeCase Action
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
      • Logic Namespace
      • Message Namespace
      • Network Namespace
      • Path Namespace
      • Settings Namespace
      • Sqlite Namespace
      • Sync Namespace
      • System Namespace
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Data.getCurrentCase Action

Format
s = CS.Data.getCurrentCase(dataId := ...,
                       
ʃ, serializationOptions := ...ʅ)
ArgumentDescriptionTypes / Required
dataIdThe resource ID returned by Data.open, or a dictionary name.number, string
recommended
serializationOptionsOptions for how the case should be serialized.object
not required
Description
The Data.getCurrentCase action returns the current case associated with an application's dictionary, returning its JSON representation. The optional serializationOptions argument allows you to specify how the case should be serialized, potentially overriding the default application settings.
The data source is identified using dataId. If specified as a string, it references the data source that is connected to a dictionary that is part of an application. If specified as a number, it is processed as a resource ID returned by Data.open. This typically references non-application data sources. While optional, this should generally be specified explicitly. (If there is only one data source open, the resource ID can be calculated implicitly.)
Because CSPro optimizes the reading of case data, you may need to disable the dictionary's Read Optimization setting when using this action on external dictionaries or in batch applications.
Return Value
The action returns the case object.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form, or if:
  • The data source ID is not valid.
  • The data source is not connected to a dictionary that is part of an application.
Example (CSPro Logic)
// construct the input needed for the questionnaire view, using the external dictionary
// attached to this application but getting the forms and question text from the disk
string questionnaireViewInput =
   
maketext("{ \"dictionary\": %s, \"forms\": %s, \"questionText\": %s, \"case\": %s }",
             
CS.Dictionary.getDictionary(name := "MARINE_DICT"),
             
CS.Application.getFormFile(path := "Marine Mammals Survey.fmf"),
             
CS.Application.getQuestionText(path := "Marine Mammals Survey.ent.qsf"),
             
CS.Data.getCurrentCase(dataId := "MARINE_DICT"));

// pass this input to the questionnaire view
CS.UI.view(path := Path.concat(html, "questionnaire-view", "index.html"),
           
inputData := @object questionnaireViewInput);
See also: Data Action Invoker Namespace, Data.readCase Action, Application.getQuestionnaireContent Action