Argument | Description | Types / Required |
contentType | The MIME type, or types, of documents displayed.
The default value is "*/*". | string, array
not required |
multiple | If true, the operator can select multiple documents.
The default value is false. | boolean
not required |
The
System.selectDocument action displays a dialog that allows the operator to select one or more documents shared by the system, returning a
sharable URI that provides access to these documents. This action is primarily for use in applications run on Android when you may want to
access files created by other applications or media such as photos taken by the device. On Android, such files are not available to CSPro directly, so this action provides a framework for accessing system documents.
The contentType argument allows you to specify the content from which you would like the operator to select. For example, specfiying "image/*" would only allow the operator to select image files. When specified as an array, it is possible to specify multiple types (e.g., "image/jpeg" and "image/png").
The multiple argument indicates whether the operator can select multiple documents.
If no documents are selected, the action returns undefined. Otherwise the action returns an object with two properties:
Property | Value |
"path" | The path, or sharable URI, of the document. |
"name" | The filename of the document, which may not necessarily be part of the path. |
For example, on Android, this object, represented in
JSON, may look like this:
{
"path": "content://com.android.providers.media.documents/document/image%03A1000002937",
"name": "carn03.jpg"
}
If
multiple is
true, an array of objects is returned, even if the operator only selects one document.
The action throws an exception if any of its arguments are not specified in a valid form.
// query for an image
string selectDocumentJson = CS.System.selectDocument(contentType := "image/*");
if selectDocumentJson <> "" then
// convert the JSON into a CSPro-usable format using a HashMap
HashMap string selectDocumentResult;
selectDocumentResult.updateValueFromJson(selectDocumentJson);
// create the new image path, using the original filename
dircreate("Images");
string imagePath = Path.concat("Images", selectDocumentResult("name"));
// copy the document to the Images directory
CS.File.copy(source := selectDocumentResult("path"),
destination := imagePath);
endif;