This server-side class allows for collecting attachments from a remote instance when performing a migration from some third-party system to SimpleOne.

SimpleAttachmentService()


Instantiates a new empty SimpleAttachmentService object.


SimpleAttachment
const attach = new SimpleAttachmentService();

createAttachmentByUrl(url, SimpleRecordId, fileName)


This method allows for getting a file from a remote instance by a URL provided.

Parameter(s):

Name

Type

Mandatory

Default Value

urlStringYN
SimpleRecordIdStringYN
fileNameStringYN


Return:

Type

Description

String or NULL
  • Success: returns the attachment ID in the cloud storage;
  • Failure: returns NULL.
createAttachmentByUrl
const attach = new SimpleAttachmentService();
attach.setUsername('john.doe'); // Put up a real username before using this method.
attach.setPassword('123456'); // Put up a real password before using this method.
const docID = ss.getDocIdByIds('155931135900000084', '155931135900000001');
const attachId = attach.createAttachmentByUrl('http://simple.instance.com/v1/attachments/download/159229954513242397', docID, 'test.sop');

setUrl(url)


This method sets a URL of the remote instance that will be accessed when the getAttachmentSN method is called.


NameTypeMandatoryDefault Value
urlStringYN
TypeDescription
VoidThis method does not return a value.

Example:

setUrl
attach.setUrl('https://simple.instance.com:8443');

setUsername(username)


This method sets a user of a remote instance whose security context is used when establishing a connection.

The user whose username is passed to the method must have sufficient access rights to the source file.

Parameter(s):

NameTypeMandatoryDefault Value
usernameStringYN

Return value:

TypeDescription
VoidThis method does not return a value.

Example:

setUsername
attach.setUsername('john.doe');

setPassword(password)


This method allows for setting password for a user whose security context is used when establishing a connection to a remote instance.

Parameter(s):

NameTypeMandatoryDefault Value
passwordStringYN

Return value:

TypeDescription
VoidThis method does not return a value.

Example:

setPassword
attach.setPassword('123456');

getAttachmentSN(SourceSysId, SimpleRecordId)


This method allows for getting a file from a remote instance by the ID of the record on that instance.

Parameter(s):

NameTypeMandatoryDefault value
SourceSysIdStringYN

SimpleRecordId

StringYN

Return value:

Type

Description

String or NULL
  • Success: returns the attachment ID in the cloud storage;
  • Failure: returns NULL.

Example:

getAttachmentSN
const attach = new SimpleAttachmentService();
attach.setUrl('https://source-now.instance.com:8443'); // A target instance. Place a real URL there before using this method.
attach.setUsername('john.doe'); // Put up a real username before using this method.
attach.setPassword('123456'); // Put up a real password before using this method.
const docID = ss.getDocIdByIds('155931135900000084', '155931135900000001');
const attachId = attach.getAttachmentSN('f91d84fe7cff58d4db91f2e9c2dc02fb', docID);

  • No labels