s = CS.Data.getCase(ʃname := ...ʅ
ʃ, key := ... ‖ uuid := ...ʅ
ʃ, serializationOptions := ...ʅ)
Argument | Description | Types / Required |
name | The name of a dictionary associated with an application. | string
not required |
key | The key (case IDs) of a specific case to lookup. | string
not required |
uuid | The UUID of a specific case to lookup. | string
not required |
serializationOptions | Options for how the case should be serialized. | object
not required |
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.
The action returns the case.
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.
// 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}`);
}
}
// 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);