Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
SimpleOne supports attaching files to existing or newly created records.
The files can be attached in three ways:
- via the attachment action and Image field.
- via the attachment widget.
Attachment action and Image field Anchor action action
action | |
action |
You can attach files to a field ofImage type and a record with the attachment action. The action is displayed on forms as the paper clip icon .
The screenshot below illustrates two attachment actions on the record form:
Attachment widget Anchor widget widget
widget | |
widget |
Attachments can be added via an attachment widget in the agent interface. For this, you need to use the <attachment> SimpleTag within a certain widget instance. It is unnecessary to specify the recordId, tableName attributes for the <attachment> tag located on the page with the form. Therefore, a widget template with an attachment tag will look like this:
Code Block |
---|
<attachment> </attachment> |
Info |
---|
After adding a widget instance to a form of the agent interface, the standard action You can add files from the clipboard to the widget directly on the form by using Ctrl+V shortcut while hovering over Drag & drop area. |
Add and manage attachments
You can attach files in the following ways:
by clicking Select files and adding them via the file manager.
by dragging and dropping files in the window.
by pressing the Ctrl(Cmd) and V keys on your keyboard to paste an image from the clipboard.
by clicking Add files and selecting them via the file manager if files have been uploaded before.
Upload a file
To attach a file to some record, complete the steps below:
Navigate to a record you need to work on.
Open the Attachments window:
Click the attachments icon
in the top right corner.
Click the attachments icon
near the field name.
Attach the file you need. Attached files appear at the top of the form or near the field name.
Close the Attachments window to return to the record.
Click Save or Save and exit.
Info |
---|
When uploading a file via the attachments icon in the top right corner, you do not need to save the record. Attached files are automatically saved on the server. |
The picture below illustrates the attachment window:
Delete a file
To delete a file uploaded earlier, complete the steps below:
Navigate to a record you need to work on.
Open the Attachments window:
Click the attachments icon
in the top right corner.
Click the attachments icon
near the field name.
Delete a file or files in the following ways:
If there is one file, click Delete.
If there are several files, point the cursor to a file you want to delete, click the three-dots icon
, and then select Choose. Repeat for other files you want to delete. Click Delete.
Click Select all and Delete to remove all uploaded files.
Close the Attachments window to return to the record.
Click Save or Save and exit.
Info |
---|
When deleting a file via the attachments icon in the top right corner, you do not need to save the record. Attached files are automatically deleted from the server. |
Copy a file
To copy attachments, use the server-side scripts. You can use one of the following ways:
Use the base64 object of the original attachment. Due to the specifics of the readBase64 method, the maximum size of the copied file is 10 Mb.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
const attachmentRec = new SimpleRecord('sys_attachment');
attachmentRec.get('167654133500015741');
ss.info(`Original size bytes: ${attachmentRec.size_bytes}`);
// Info: Original size bytes: 92414492
const attach = new SimpleAttachment();
const base64Value = attach.readBase64(attachmentRec.sys_id);
const attachCopyId = attach.writeBase64(
attachmentRec.record_document_id,
'copy_of_' + attachmentRec.file_name,
base64Value,
attachmentRec.mime_content_type
);
if (attachCopyId) {
attachmentRec.get(attachCopyId);
ss.info(`/record/sys_attachment/${attachCopyId}`);
// Info: /record/sys_attachment/167654428100399185
ss.info(`Copy size bytes: ${attachmentRec.size_bytes}`);
// Info: Copy size bytes: 0
} |
Use the SimpleAttachmentService class. The maximum size of the copied file depends on the instance-wide limit that is specified in the max_file_size_upload system property.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
const attachmentRec = new SimpleRecord('sys_attachment');
attachmentRec.get('167654133500015741');
ss.info(`Original size bytes: ${attachmentRec.size_bytes}`);
// Info: Original size bytes: 92414492
const importSource = new SimpleRecord('sys_import_source');
importSource.get('167647710807446665'); // From Incident Import Source
const docId = ss.getDocIdByIds(importSource.sys_db_table_id, importSource.sys_id);
const attach = new SimpleAttachment();
const attachUrl = attach.getAttachmentUrlById(attachmentRec.sys_id);
const simpleAttach = new SimpleAttachmentService();
const docID = ss.getDocIdByIds(importSource.sys_db_table_id, importSource.sys_id);
const attachCopyId = simpleAttach.createAttachmentByUrl(attachUrl, docId, `Copy_of_the_${attachmentRec.file_name}`);
if (attachCopyId) {
attachmentRec.get(attachCopyId);
ss.info(`/record/sys_attachment/${attachCopyId}`);
// Info: /record/sys_attachment/167654472004676912
ss.info(`Copy size bytes: ${attachmentRec.size_bytes}`);
// Info: Copy size bytes: 92414492
} |
Parsing and indexing
Parsing and indexing attachment content is possible only if the attachment file size is under 30 MB. The limit is fixed and cannot be modified. If the file is bigger than 30 MB, it will not be indexed. The warning message related to the indexation is written to logs. You will be able to find more information later in the Main Log (sys_log) table using the criteria below for the filter:
Level IS Warning
Message Contains {Attachment ID}
Indexing is performed only for specific file formats. The Content field on the Attachment form will be automatically filled with the text content of the attached file if the file extension is included in the list: TXT, INI, REG, CVS, JSON, HTM, HTML, DOC, DOCS, XLS, XLSX. The Full text search is enabled within the Content field, which allows you to perform a global search on the field's content.
Note | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The attachment parsing and indexing process is asynchronous. Within this process, the following events are implemented: | |||||||||||||||
Info | |||||||||||||||
Depending on the publicity of an attachment, two links can be generated. For example:
|
Attachment Download URL
Attachment links can be used for various purposes:
- downloading a single file from attachments.
- download all files from attachments as an archive.
- using a link to a file from attachments in HTML tags.
Apart from this, links can also be used to:
- add images to the body of the HTML field.
- add images to the widget by setting the value of the scr attribute.
Attachment records can be public or non-public. The publicity of attachments affects whether an attachment link will have an expiration date.
- Links to public attachments do not expire.
- Non-public attachments have a lifetime of 1 hour by default from the moment they are generated. The lifetime of a link is determined through the system property s3.presigned.link.lifetime.
The Public attribute on the Attachment form defines the publicity of attachments.
To generate attachment links, log in and use the relative link /attachments/${sys_attachment.sys_id} to download attachments. You can also use the getAttachmentUrlById(attachmentId) method to generate a link via the API. For more information, see the SimpleAttachments article.
|
Table of Contents | ||||||
---|---|---|---|---|---|---|
|