Argument | Description | Types / Required |
name | The name of a form file associated with an application. | string
not required |
path | The path of a form file to read. | string
not required |
The
Application.getFormFile action returns a form file associated with an application or loaded from the disk. One, and only one, of the arguments
name or
path must be provided.
If specifying
name, you can also specify the name of an
application or
dictionary. When using an application name, the application's main form file is returned. When using a dictionary name, the form file associated with that dictionary is returned.
If neither name nor path are specified, the application's main form file is returned.
The action returns the form file.
The action throws an exception if any of its arguments are not specified in a valid form, or if:
- No form file, or associated form file, exists with the specified name.
- The name identifies a dictionary that does not have an associated form file.
- The form file does not exist or cannot be read.
// write to the console all of the field names and their capture types
const formFile = CS.Application.getFormFile({
path: "Census Data Entry.fmf"
});
function iterateOverItems(entity) {
if( entity.items === undefined ) {
return;
}
entity.items.forEach(item => {
if( item.type === "field" ) {
console.log(`${item.name}: ${item.capture.type}`);
}
else {
iterateOverItems(item);
}
});
}
formFile.levels.forEach(level => {
iterateOverItems(level);
});
// 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);