Class: AttachmentFormCellProxy¶
AttachmentFormCellProxy is a developer-facing interface that provides access to an 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¶
-
AttachmentFormCellProxy
Implements¶
Summary¶
Constructors¶
Properties¶
Class Properties¶
Currently none in this class.
Inherited Properties¶
Accessors¶
Class Accessors¶
Currently none in this class.
Inherited Accessors¶
Methods¶
Class Methods¶
- getAllowedFileTypes
- getAttachmentActionType
- getAttachmentAddTitle
- getAttachmentCancelTitle
- getAttachmentTitle
- getMaxAttachments
- getMaxFileSize
- openAttachmentItem
- setAllowedFileTypes
- setAttachmentActionType
- setAttachmentAddTitle
- setAttachmentCancelTitle
- setAttachmentTitle
- setMaxAttachments
- setMaxFileSize
- setValueByIndex
Inherited Methods¶
Constructors¶
constructor¶
+ new AttachmentFormCellProxy(context: IContext): AttachmentFormCellProxy
Overrides FormCellControlProxy.constructor
Parameters:
| Name | Type |
|---|---|
context |
IContext |
Returns: AttachmentFormCellProxy
Methods¶
getAllowedFileTypes¶
▸ getAllowedFileTypes(): string[]
Implementation of IAttachmentFormCellProxy
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[]
Implementation of IAttachmentFormCellProxy
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
Implementation of IAttachmentFormCellProxy
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
Implementation of IAttachmentFormCellProxy
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
Implementation of IAttachmentFormCellProxy
Returns the AttachmentTitle property value defined for the FormCell's control.
example
// 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
Implementation of IAttachmentFormCellProxy
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
Implementation of IAttachmentFormCellProxy
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): void
Implementation of IAttachmentFormCellProxy
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: void
setAllowedFileTypes¶
▸ setAllowedFileTypes(fileType: [string]): Promise‹any›
Implementation of IAttachmentFormCellProxy
This method is used for setting the allowed file types for attachments. If no value is specified for the AllowedFileTypes property, users are allowed to select any type of file. This property can contain values in the form of an array, such as ["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›
Implementation of IAttachmentFormCellProxy
This method is used for setting the attachment action types, specifically for changing the value of the AttachmentActionType property. The value is an array that can contain '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›
Implementation of IAttachmentFormCellProxy
This method is used to set the title bar of the add attachment menu, specifically 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›
Implementation of IAttachmentFormCellProxy
This method is used to set the title of the cancel button on the add attachment menu, specifically 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: Promise‹any›
setAttachmentTitle¶
▸ setAttachmentTitle(title: string): Promise‹any›
Implementation of IAttachmentFormCellProxy
This method is used to set the title of the attachment container, specifically for changing the value of the AttachmentTitle property. The default value is 'Attachments (%d)', where %d is substituted with the actual count of the attachments.
example
// 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›
Implementation of IAttachmentFormCellProxy
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(maxFileSize: number): Promise‹any›
Implementation of IAttachmentFormCellProxy
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 |
|---|---|
maxFileSize |
number |
Returns: Promise‹any›
setValueByIndex¶
▸ setValueByIndex(value: any, index: number, notify?: boolean): this
Implementation of IAttachmentFormCellProxy
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: this
this - allows chaining