Skip to content

Attachment

This container item allows users to add or take a photo as an attachment.

Attachment Properties

Property Type Required Default
AllowedFileTypes string[] Optional
AttachmentActionType enum[] Required
AttachmentAddTitle string Optional "Add"
AttachmentTitle string Optional "Attachment (%d)"
AttacmentCancelTitle string Optional "Cancel"
IsVisible boolean Optional true
OnValueChange ActionOrRule Optional
Styles object Optional
Value object[] Optional
_Name string Required
_Type const Required

AllowedFileTypes

List of file types which can be uploaded. Only applicable when AttachmentActionType is SelectFile.

Refer to Android file types and iOS file types for details.

If the customized file types are not supported by Android or iOS, you can assign an empty array, i.e. [], to allow choosing all files.

In iOS, since odt, docx, xlsx and pptx are all actually contained in a zip file wrapper, they also conform to 'zip' format. So, when you specify 'zip' in the list, it also includes all other types that conform to 'zip' format.

  • type: string[]

All items must be of the type: string


AttachmentActionType

List of supported attachment types.

  • type: enum[]
Value
AddPhoto
TakePhoto
SelectFile

All items must be of the type: string


AttachmentAddTitle

Title string for the add attachment popover. Android only.

  • type: string
  • default: "Add"

AttachmentTitle

String for the attachment header. Parameterized strings are accepted as well, e.g. 'Photos [%d]', where the parameter is substituted by the number of attachments.

  • type: string
  • default: "Attachment (%d)"

AttacmentCancelTitle

Title string for the cancel button on the add attachment popover.

  • type: string
  • default: "Cancel"

IsVisible

Sets the visibility of the control.

  • type: boolean
  • default: true

OnValueChange

Action or rule to perform after a new attchment is added or an existing attachment is deleted.


Styles

Set styles for Background.

  • type: object with following properties.
Property Type Required Default
Background string Optional

Background

The string value is a style class name for Background.


Value

List of resources which are to be added by default. Each item is in accordance with the interface IAttachment definition.

  • type: object[]

_Name

  • type: string

_Type

  • type: const

The value of this property must be equal to:

"Control.Type.FormCell.Attachment"

Android Platforms File Types List

Android Version Link
9.0 https://android.googlesource.com/platform/libcore/+/refs/tags/android-9.0.0_r49/luni/src/main/java/libcore/net/MimeUtils.java
8.1 https://android.googlesource.com/platform/libcore/+/refs/tags/android-8.1.0_r69/luni/src/main/java/libcore/net/MimeUtils.java
8.0 https://android.googlesource.com/platform/libcore/+/refs/tags/android-8.0.0_r39/luni/src/main/java/libcore/net/MimeUtils.java
7.1.1 https://android.googlesource.com/platform/libcore/+/refs/tags/android-7.1.1_r59/luni/src/main/java/libcore/net/MimeUtils.java
7.0 https://android.googlesource.com/platform/libcore/+/refs/tags/android-7.0.0_r36/luni/src/main/java/libcore/net/MimeUtils.java
6.0 https://android.googlesource.com/platform/libcore/+/refs/tags/android-cts-6.0_r32/luni/src/main/java/libcore/net/MimeUtils.java

Examples

// Attachment Form Cell metadata
{
  "_Type": "Page",
  "_Name": "FormCellsPage",
  "Caption": "FormCell Example",
  "Controls": [{
    "_Type": "Control.Type.FormCellContainer",
    "_Name": "FormCellContainer",
    "Sections": [{
      "Caption": "Section",
      "Controls": [{
        "_Type": "Control.Type.FormCell.Attachment",
        "_Name": "AttachmentFormCell",
        "AttachmentTitle": "Photos [%d]",
        "AttachmentAddTitle": "Add photos",
        "AttachmentCancelTitle": "No!",
        "AttachmentActionType": ["AddPhoto", "TakePhoto", "SelectFile"],
        "AllowedFileTypes": [ "jpg", "png", "gif" ],
        "OnValueChange": "/MyMDKApp/Actions/ShowMessage.action",
        "Styles": {
          "Background": "AttachmentFormCellBackground"
        }
      }]
    }]
  }]
}

Set attachment Value from a Rule

// Attachment Form Cell metadata
{
  "_Type": "Page",
  "_Name": "FormCellsPage",
  "Caption": "FormCell Example",
  "Controls": [{
    "Sections": [{
      "_Type": "Control.Type.FormCellContainer",
      "_Name": "FormCellContainer",
      "Caption": "Section",
      "Controls": [{
        "_Type": "Control.Type.FormCell.Attachment",
        "_Name": "AttachmentFormCell",
        "AttachmentTitle": "Photos [%d]",
        "AttachmentAddTitle": "Add photos",
        "AttachmentCancelTitle": "No!",
        "AttachmentActionType": ["AddPhoto", "TakePhoto", "SelectFile"],
        "Value": "/MyMDKApp/Rules/InitializeAttachments.js",
        "AllowedFileTypes": ["jpg", "png", "gif"],
        "OnValueChange": "/MyMDKApp/Actions/ShowMessage.action"
      }]
    }]
  }]
}
// set local attachments to Value property
// InitializeAttachments.js
function InitializeAttachments(formcellProxy) {
    var serviceName = '/MyMDKApp/Services/Amw.service';
    var entitySet = 'Images';
    var queryOption = '$top=1'
    var promises = [];
    var attachmentData = [];
    return formcellProxy.read(serviceName, entitySet, [], queryOption).then(function (attachments) {
        attachments.forEach(function (attachmentObject) {
            var documentObject = attachmentObject.Document;
            var readLink = documentObject['@odata.readLink'];
            var entitySet = readLink.split('(')[0];
            promises.push(formcellProxy.isMediaLocal(serviceName, entitySet, readLink).then(function (isMediaLocal) {
                return [isMediaLocal, documentObject];
            }));
        });

        return Promise.all(promises).then(function (results) {
            results.forEach(function (result) {
                var isMedialLocal = result[0];
                var attachment = result[1];
                if (isMedialLocal && !attachment.FileSize) {
                    var entitySet = 'Documents';
                    var property = 'Document';
                    var readLink = attachment['@odata.readLink'];
                    var service = '/MyMDKApp/Services/Amw.service';
                    var documentPath = attachment.path;
                    var attachmentEntry = formcellProxy.createAttachmentEntry(documentPath, entitySet, property, readLink, service);
                    if (attachmentEntry) {
                        attachmentData.push(attachmentEntry);
                    }
                }
            });
            return attachmentData;
        });
    });
}

Style Classes Definition

/* Attachment Form Cell - Background */
.AttachmentFormCellBackground {
  background-color: yellow;
}