Skip to content

Overview

Due to platform restrictions on data table attachment field access rules, preview images for attachment and signature fields cannot be displayed in views. In this case, we need to process the data and add the following fields to attachment and signature fields.

Field IdentifierName
appIdApplication ID from which the field value originates
tableIdData Table Identifier from which the field value originates
fieldIdField Identifier from which the field value originates

Scenario Example

Example Data Tables

Assume that in Application A (com.test.a), there are Data Table A (with identifier tablea) and Data Table B (tableb) with the following table structures.

Data Table A

Field IdentifierNameType
nameNameSingle-line Text
attachmentAttachmentAttachment
signatureSignatureHandwritten Signature

Data Table B

Field IdentifierNameType
nameNameSingle-line Text
attachmentAttachmentAttachment
signatureSignatureHandwritten Signature

The data in Data Table B comes from a script as follows.

javascript
export function executeQueryList(ctx) {
    var list = informat.table.queryList('tablea', {
        includeFields: ['attachment', 'signature'],
    });
    return list;
}

export function executeQueryListCount(ctx) {
    return 100;
}

Modify the above query script as follows.

javascript
export function executeQueryList(ctx) {
    var list = informat.table.queryList('tablea', {
        includeFields: ['attachment', 'signature']
    });
    // var appId = informat.app.appId(); // Use this method if it's the same application
    var appId = informat.app.getAppIdByKey('com.test.a');
    var result = list.map(record => {
        let attachment = null;
        let signature = null;
        // If the attachment is multi-select, you need to use forEach to iterate
        if (record.attachment) {
            // Data copy
            attachment = JSON.parse(informat.utils.toJSON(record.attachment));
            attachment = {
                ...attachment,
                appId: appId,
                tableId: 'tablea',
                fieldId: 'attachment'
            };
        }
        // If the signature is multi-select, you need to use forEach to iterate
        if (record.signature) {
            // Data copy
            signature = JSON.parse(informat.utils.toJSON(record.signature));
            signature = {
                ...signature,
                appId: appId,
                tableId: 'tablea',
                fieldId: 'signature'
            };
        }
        return {
            id: record.record,
            attachment: attachment,
            signature: signature
        };
    });
    return list;
}

export function executeQueryListCount(ctx) {
    return 100;
}

At this point, the platform client will prioritize using the Application ID, Data Table Identifier, and Field Identifier information in the attachment or signature item for rendering.