• <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.readCase Action

Format
s = CS.Data.readCase(dataId := ...,
                     
key := ... ‖ uuid := ... ‖ position := ...
                 
ʃ, serializationOptions := ...ʅ)
ArgumentDescriptionTypes / Required
dataIdThe resource ID returned by Data.open, or a dictionary name.number, string
recommended
keyThe key (case IDs) of a case.string
not required
uuidThe UUID of a case.string
not required
positionThe "position" of a case.number
not required
serializationOptionsOptions for how the case should be serialized.object
not required
Description
The Data.readCase action reads a case from a data source, 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.)
The case is specified by using one of the data source case identifiers:
  • key: When specifying a key (case IDs), only non-deleted cases are matched.
  • uuid: Specifying a case's UUID allows matching on all cases, including deleted cases. Note that not all data sources use UUIDs.
  • position: Identification by the "location" of the case in the data source also matches on all cases. Note that the position value can change when the data source is modified.
One of these case identifiers must be specified. If multiple identifiers are specified, uuid is prioritized over position, which is prioritized over key.
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.
This action is similar to the CSPro logic function loadcase.
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 specified case does not exist in the data source.
  • There is an error interacting with the data source.
Example (JavaScript)
// read a case with a specific key
const caseData = CS.Data.readCase({
    dataId: 
"CLIMATE_DICT",
    key: 
"010112600910970251",
    serializationOptions: {
        writeLabels: 
true
    }
});

// display the value of all ID items along with their labels
for (const [name, idOrRecord] of Object.entries(caseData.CLIMATE_LEVEL)) {
   
if (!Array.isArray(idOrRecord)) {
        print(`${name}: ${idOrRecord.code} - ${idOrRecord.label}`);
    }
}
See also: Data Action Invoker Namespace, Data.getCurrentCase Action, Data.queryCases Action, Data.writeCase Action, LoadCase Function