You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 17 Next »
This server class provides methods that allow operating with attachments.
SimpleAttachment()
Instantiates a new empty SimpleAttachment object.
let attach = new SimpleAttachment();
base64Decode(data)
This method returns an ASCII string decoded from the base64 string specified.
Name | Type | Mandatory | Default Value |
---|---|---|---|
data | String | Y | N |
Return:
Type | Description |
---|---|
String | The decoded string. |
Example:
base64Encode(data)
This method returns a Base64 string from the string specified.
Name | Type | Mandatory | Default Value |
---|---|---|---|
data | String | Y | N |
Return:
Type | Description |
---|---|
String | The encoded Base64 string. |
Example:
copy(sourceTable, sourceID, targetTable, targetID)
This method copies attachments from the source record to the target record.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
sourceTable | String | Y | N |
sourceID | String | Y | N |
targetTable | String | Y | N |
targetID | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
let attach = new SimpleAttachment(); attach.copy('user', '155964310500000059', 'sys_script', '155964310500000051');
createAttachmentByUrl(url, SimpleRecordId, fileName)
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
url | String | Y | N |
SimpleRecordId | String | Y | N |
fileName | String | Y | N |
Return:
Type | Description |
---|---|
String |
Example:
deleteAttachment(attachmentID)
This method deletes the specified attachment.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
attachmentID | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
let attach = new SimpleAttachment(); attach.deleteAttachment('157052637119478714');
getCloudStorageUrl(attachmentId)
This method allows to get the URL of the specified attachment at the cloud storage.
Name | Type | Mandatory | Default Value |
---|---|---|---|
attachmentId | string | Y | N |
Return:
Type | Description |
---|---|
String | This method returns the attachment URL in the cloud storage. |
Example:
getContent(sysAttachment)
This method gets attachment content as a string.
Name | Type | Mandatory | Default Value |
---|---|---|---|
sysAttachment | SimpleRecord | Y | N |
Return:
Type | Description |
---|---|
String | The attachment content as a string. |
Example)
let attach = new SimpleAttachment(); let content = attach.getContent('157052637119478714');
rename(attachmentId, fileName)
This method renames the specified attachment.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
attachmentId | String | Y | N |
fileName | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
let attach = new SimpleAttachment(); attach.rename('157052637119478714', 'new_name_1.png');
write(record, fileName, contentType, content)
This method inserts the attachment to the record specified.
Name | Type | Mandatory | Default Value |
---|---|---|---|
record | SimpleRecord | Y | N |
filename | String | Y | N |
contentType | String | Y | N |
content | String | Y | N |
Return
Type | Description |
---|---|
String | The attachment's sys ID. |
Example:
let attach = new SimpleAttachment(); let record = attach.write('157052637119478714', 'readme.md', 'text/markdown', '# h1 title');
writeBase64(documentId, fileName, base64, contentType)
This method inserts the attachment to the record specified using Base64 encoding.
Name | Type | Mandatory | Default Value |
---|---|---|---|
documentID | String | Y | N |
fileName | String | Y | N |
base64 | String | Y | N |
contentType | String | Y | N |
Return
Type | Description |
---|---|
String or NULL | The attachment's sys ID; in case of error; returns NULL. |
Example:
- No labels