Skip to main content
Handles Service attachments.

Constructors

Attachment()

Initializes a new instance of the Attachment class.

Methods

dump()

Dumps the attachment file to output.
Returns: CRMScript.Global.Bool - True if everything is OK; otherwise false.
Use dump(Bool) to signal the browser to download the file instead of display it.

dump(Bool)

Dumps the attachment file to output. The optional parameter if true tells the browser to download the file, and not attempt to display it.
Returns: CRMScript.Global.Bool - True if everything is OK; otherwise false.

getBase64()

Returns the attachment as base64 encoded string.
Returns: CRMScript.Global.String - The attachment as base64 encoded string.
This can be used to load a binary attachment into a string, as base64 coded data is valid ASCII.

getDownloadUrl(Bool,Bool)

Constructs a download URL for the attachment.
Returns: CRMScript.Global.String - The download URL for the attachment.
There are 2 kinds of URLs: external = used by customers; internal = used by Service users.

getRaw()

Gets the whole attachment as a String without any special encoding.
Returns: CRMScript.Global.String - The raw attachment without any special encoding.

getValue(String)

Gets a value from the attachment class.
Returns: CRMScript.Global.String - The value of the property given in name.
The current implementation supports the following values as the name parameter.
  • id: the attachment ID
  • contentType: content descriptor
  • name: the filename
  • size: size in bytes
  • key: authentication key
  • charset
  • dbiAgentId
  • dbiKey
  • dbiLastModified
  • dbiLastSyncronized

load(Integer)

Loads a Service attachment from disk.
Returns: CRMScript.Global.Bool - True if the load was successful; otherwise false.

remove()

Deletes the attachment record from the database and the attachment file from disk.
Returns: CRMScript.Global.Void

save()

Saves the attachment to disk.
Returns: CRMScript.Global.Integer - The attachment ID.

saveBase64(String)

Creates a filename and saves a base64-coded attachment to disk.
Returns: CRMScript.Global.Integer - The actual number of bytes written to disk.

setValue(String,String)

Sets a value on the attachment object.
Returns: CRMScript.Global.Void
The current implementation supports the following values as the name parameter.
  • id: the attachment ID
  • contentType: content descriptor
  • name: the filename
  • size: size in bytes
  • key: authentication key
  • charset
  • dbiAgentId
  • dbiKey
  • dbiLastModified
  • dbiLastSyncronized