• <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
        • Data Action Invoker Namespace
        • Data.getCase Action
      • 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>

Data.getCase Action

Format
s = CS.Data.getCase(ʃname := ...ʅ
                 
ʃ, key := ... ‖ uuid := ...ʅ
                 
ʃ, serializationOptions := ...ʅ)
ArgumentDescriptionTypes / Required
nameThe name of a dictionary associated with an application.string
not required
keyThe key (case IDs) of a specific case to lookup.string
not required
uuidThe UUID of a specific case to lookup.string
not required
serializationOptionsOptions for how the case should be serialized.object
not required
Description
The Data.getCase action returns a specific case, or the current case, associated with a dictionary. The optional serializationOptions argument allows you to specify how the case should be serialized, potentially overriding the default application settings.
Typically name identifies a dictionary, but you can also specify the name of an application or form file. When using an application name, or if name is not specified, the case associated with the application's main dictionary is returned. When using a form file name, the case associated with that form file's dictionary is returned.
If neither key nor uuid are specified, the current case associated with the dictionary is returned. If one of those arguments is specified, the case identified by that argument is returned. If both key and uuid are specified, then the uuid value is prioritized.
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.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form, or if:
  • No dictionary, or associated dictionary, exists with the specified name.
  • No case exists as specified by the key or uuid arguments.
  • An error occurs while reading the case from the data source.
Example (JavaScript)
// get the case with a specific key
let caseData = CS.Data.getCase({
    name: 
"CLIMATE_DICT",
    key: 
"010112600910970251",
    serializationOptions: {
        writeLabels: 
true
    }
});

// write to the console the value of all ID items along with their labels
for( const [name, idOrRecord] of Object.entries(caseData.CLIMATE_LEVEL) ) {
   
if( !Array.isArray(idOrRecord) ) {
        console.log(`${name}: ${idOrRecord.code} - ${idOrRecord.label}`);
    }
}
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.getCase(name := "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, Application.getQuestionnaireContent Action