Skip to content

Interface: IAttachmentFormCellProxy

AttachmentFormCellProxy is a developer-facing interface that provides access to a Attachment control and allows customizations. In addition it provides access to the IFormCellProxy interface.

example

// Configure attachment control with custom settings
export default function ConfigureAttachments(pageProxy) {
  const attachmentFormCell = pageProxy.evaluateTargetPathForAPI("#Control:AttachmentFormCell");

  // Set custom titles and action types
  attachmentFormCell.setAttachmentTitle("Photos [%d]");
  attachmentFormCell.setAttachmentAddTitle("Add photos");
  attachmentFormCell.setAttachmentCancelTitle("No!");
  attachmentFormCell.setAttachmentActionType(["AddPhoto", "TakePhoto", "SelectFile"]);

  // Restrict to image files only
  attachmentFormCell.setAllowedFileTypes([".jpeg", ".png", ".gif"]);

  // Set maximum attachments and file size limits
  attachmentFormCell.setMaxAttachments(5);
  attachmentFormCell.setMaxFileSize(10); // 10 MB limit

  // Call inherited methods
  attachmentFormCell.getValue();
}

Hierarchy

Implemented by

Summary

Properties

Class Properties

Currently none in this class.

Inherited Properties

Methods

Class Methods

Inherited Methods

Methods

getAllowedFileTypes

getAllowedFileTypes(): string[]

Returns the AllowedFileTypes property value defined for the FormCell's control.

example

// Check current file type restrictions
const sectionedTable = pageProxy.getControl('SectionedTable');
const attachmentFormCell = sectionedTable.getSection('AttachmentSection').getControl('AttachmentControl');
const allowedTypes = attachmentFormCell.getAllowedFileTypes();
console.log("Allowed file types:", allowedTypes.toString());

Returns: string[]


getAttachmentActionType

getAttachmentActionType(): string[]

Returns the AttachmentActionType property value defined for the FormCell's control.

example

// Configure UI based on available attachment action types
const attachmentFormCell = pageProxy.getControl('DocumentAttachment');
const actionTypes = attachmentFormCell.getAttachmentActionType();

// Show different instruction text based on available options
const instructionLabel = pageProxy.getControl('InstructionText');
if (actionTypes.includes('TakePhoto') && actionTypes.includes('AddPhoto') && actionTypes.includes('SelectFile')) {
  instructionLabel.setValue('Take a photo, select from gallery, or choose a file');
} else if (actionTypes.includes('TakePhoto') && actionTypes.includes('AddPhoto')) {
  instructionLabel.setValue('Take a photo or select from gallery');
} else if (actionTypes.includes('SelectFile')) {
  instructionLabel.setValue('Select a file to attach');
}

console.log('Available attachment actions:', actionTypes);

Returns: string[]


getAttachmentAddTitle

getAttachmentAddTitle(): string

Returns the AttachmentAddTitle property value defined for the FormCell's control.

example

// Validate attachment configuration
const sectionedTable = pageProxy.getControl('SectionedTable');
const attachmentFormCell = sectionedTable.getSection('FormSection').getControl('AttachmentFormCell');
const addTitle = attachmentFormCell.getAttachmentAddTitle();
const actionTypes = attachmentFormCell.getAttachmentActionType();

// Check if setup is configured for document scanning
if (addTitle.includes("Scan") && !actionTypes.includes("TakePhoto")) {
  console.log("Warning: Scan title set but camera action not enabled");
}

Returns: string


getAttachmentCancelTitle

getAttachmentCancelTitle(): string

Returns the AttachmentCancelTitle property value defined for the FormCell's control.

example

// Get current cancel title for validation
const attachmentFormCell = pageProxy.getControl('AttachmentFormCell');
const cancelTitle = attachmentFormCell.getAttachmentCancelTitle();
console.log("Cancel button shows:", cancelTitle);

**Returns:** *string*

___

###  getAttachmentTitle

 **getAttachmentTitle**(): *string*



Returns the AttachmentTitle property value defined for the FormCell's control.

**`example`** 
```javascript
// Get current attachment title for logging
const formContainer = pageProxy.getControl('FormCellContainer');
const attachmentFormCell = formContainer.getControl('AttachmentFormCell');
const message = "AttachmentTitle: " + attachmentFormCell.getAttachmentTitle();
console.log(message);

Returns: string


getMaxAttachments

getMaxAttachments(): number

Returns the maximum number of attachments that can be uploaded.

example

// Check if attachment limit has been reached
const attachmentFormCell = pageProxy.getControl("AttachmentFormCell");
const maxAttachments = attachmentFormCell.getMaxAttachments();
const currentCount = attachmentFormCell.getValue().length;
if (currentCount >= maxAttachments) {
  console.log("Maximum attachments reached:", maxAttachments); // Or other operations like show warning, etc.
}

Returns: number


getMaxFileSize

getMaxFileSize(): number

Returns the maximum file size (in megabytes) allowed for each attachment.

example

// Check file size limit before upload validation
const attachmentFormCell = pageProxy.getControl("AttachmentFormCell");
const maxSize = attachmentFormCell.getMaxFileSize();
console.log("Maximum file size allowed:", maxSize + " MB");

Returns: number


openAttachmentItem

openAttachmentItem(index: number): any

Open the item of the specified attachment at given index

example

// Open the first attachment programmatically
const attachmentFormCell = pageProxy.getControl("AttachmentFormCell");
const attachments = attachmentFormCell.getValue();
if (attachments && attachments.length > 0) {
  attachmentFormCell.openAttachmentItem(0); // Open first attachment
}

Parameters:

Name Type Description
index number The index of the item

Returns: any


setAllowedFileTypes

setAllowedFileTypes(fileType: [string]): Promise‹any›

This method is for setting the attachment allowed file types, i.e. If no specified value for this the AllowedFileTypes property, it allow user select any type of file; this property can contain the values just like ["pdf","jpg", "..."].

example

// Restrict to image files only
const attachmentFormCell = pageProxy.evaluateTargetPathForAPI("#Control:AttachmentFormCell");
attachmentFormCell.setAllowedFileTypes([".jpeg", ".png", ".gif"]);

// Allow documents and images
attachmentFormCell.setAllowedFileTypes([".pdf", ".jpeg", ".png"]);

// iOS special case: Using "zip" includes Office documents
// On iOS, odt, docx, xlsx, pptx files are zip-based formats
// So specifying "zip" will also allow these Office document types
attachmentFormCell.setAllowedFileTypes(["zip", ".pdf", ".jpeg"]);

Parameters:

Name Type Description
fileType [string] value to set.

Returns: Promise‹any›


setAttachmentActionType

setAttachmentActionType(actionType: [string]): Promise‹any›

This method is for setting the attachment action types, i.e. for changing the value of the AttachmentActionType property. Currently just the photo library and the camera are supported as attachment sources, so the value can contain just the values 'AddPhoto' and/or "TakePhoto" and/or "SelectFile".

example

// Configure all attachment action types
const attachmentFormCell = pageProxy.evaluateTargetPathForAPI("#Control:AttachmentFormCell");
attachmentFormCell.setAttachmentActionType(["AddPhoto", "TakePhoto", "SelectFile"]);

// Or limit to only camera functionality
attachmentFormCell.setAttachmentActionType(["TakePhoto"]);

Parameters:

Name Type
actionType [string]

Returns: Promise‹any›


setAttachmentAddTitle

setAttachmentAddTitle(addTitle: string): Promise‹any›

This method is for setting the title bar of the add attachment menu, i.e. for changing the value of the AttachmentAddTitle property. The default value is 'Add'.

example

// Dynamically set add title based on attachment type context
const attachmentFormCell = context.getPageProxy().getControl("AttachmentFormCell");
const entityType = context.getClientData().entityType;

if (entityType === 'DocumentEntity') {
  attachmentFormCell.setAttachmentAddTitle("Upload Document");
} else if (entityType === 'ReceiptEntity') {
  attachmentFormCell.setAttachmentAddTitle("Scan Receipt");
} else {
  attachmentFormCell.setAttachmentAddTitle("Add Files");
}

Parameters:

Name Type Description
addTitle string value to set.

Returns: Promise‹any›


setAttachmentCancelTitle

setAttachmentCancelTitle(cancelTitle: string): Promise‹any›

This method is for setting the title of the cancel button on the add attachment menu, i.e. for changing the value of the AttachmentCancelTitle property. The default value is 'Cancel'.

example

// Set a custom cancel button title
const attachmentFormCell = pageProxy.evaluateTargetPathForAPI("#Control:AttachmentFormCell");
attachmentFormCell.setAttachmentCancelTitle("No!");

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`cancelTitle` | string | value to set. |

**Returns:** *Promiseany*

___

###  setAttachmentTitle

 **setAttachmentTitle**(`title`: string): *Promiseany*



This method is for setting the title of the attachment container, i.e. for changing
the value of the AttachmentTitle property. The default value is 'Attachment (%d)', where %d
is substituted by tha actual count of the attachments.

**`example`** 
```javascript
// Update attachment title based on current attachment count and content
const attachmentControl = context.getPageProxy().getControl("DocumentAttachment");
const currentAttachments = attachmentControl.getValue();
const count = currentAttachments ? currentAttachments.length : 0;
const maxLimit = attachmentControl.getMaxAttachments();

// Customize title based on attachment count and type
if (count < maxLimit) {
  attachmentControl.setAttachmentTitle("Add Documents (%d)");
} else {
  attachmentControl.setAttachmentTitle("Add Documents (%d) - Limit Reached");
}

console.log(`Attachment title updated. Current count: ${count}`);

Parameters:

Name Type Description
title string value to set.

Returns: Promise‹any›


setMaxAttachments

setMaxAttachments(maxNumber: number): Promise‹any›

Sets the maximum number of attachments that can be uploaded.

example

// Dynamic attachment limits based on document type
const documentTypeControl = context.getPageProxy().getControl("DocumentTypeSegmented");
const attachmentControl = context.getPageProxy().getControl("DocumentAttachment");
const selectedType = documentTypeControl.getValue();

// Set different limits based on document type
if (selectedType === "Invoice") {
  attachmentControl.setMaxAttachments(3); // Invoice + 2 supporting docs
} else if (selectedType === "Report") {
  attachmentControl.setMaxAttachments(10); // Multiple charts and images
} else if (selectedType === "Profile") {
  attachmentControl.setMaxAttachments(1); // Single profile photo
} else {
  attachmentControl.setMaxAttachments(5); // Default limit
}

console.log(`Max attachments set to: ${attachmentControl.getMaxAttachments()}`);

Parameters:

Name Type
maxNumber number

Returns: Promise‹any›


setMaxFileSize

setMaxFileSize(maxNumber: number): Promise‹any›

Sets the maximum file size (in megabytes) allowed for each attachment.

example

// Set file size limit for optimization
const attachmentFormCell = pageProxy.evaluateTargetPathForAPI("#Control:AttachmentFormCell");
attachmentFormCell.setMaxFileSize(5.3); // Limit to 5.3 MB

Parameters:

Name Type
maxNumber number

Returns: Promise‹any›


setValueByIndex

setValueByIndex(value: any, index: number, notify?: boolean): any

Set the item's value in the attachment control. The value should be generated from: FormCellControlProxy.createAttachmentEntry() or AttachmentEntryProxy.createAttachmentEntry()

example

// Replace a specific attachment at index 1
const attachmentFormCell = pageProxy.getControl("AttachmentFormCell");
const newImagePath = '/path/to/replacement.jpg';
const newEntry = attachmentFormCell.createAttachmentEntry(newImagePath, 'Images', 'image', 'readLink123', '/MDKApp/Services/MyService.service');

if (newEntry) {
  attachmentFormCell.setValueByIndex(newEntry, 1, true);
}

Parameters:

Name Type Description
value any value to be set
index number The index of the item
notify? boolean whether to triggers the OnValueChange event on the FormCell's control

Returns: any

this - allows chaining