Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
With this This server-side class you can provides methods to collect attachments from a remote instance when when migrating data from a third-party system to SimpleOne.
SimpleAttachmentService()
Use this constructor to create an SimpleAttachmentService object to work with the methods described below.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const attach = new SimpleAttachmentService(); |
createAttachmentByUrl(url, recordDocId, fileName)
Use this method to create a copy of an attachment from a remote instance by a URL provided and attach it to the specified DocumentID Document ID in the recordDocId parameter.
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
url | String | Y | N |
recordDocId | String | Y | N |
fileName | String | Y | N |
Return:
Type | Description |
---|---|
String | If a file is received, the method returns the ID of the created attachment. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const attach = new SimpleAttachmentService(); attach.setUsername('john.doe'); // Specify a real username before using this method. attach.setPassword('123456'); // Specify 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)
Use this method to specify a URL of a remote instance to access to work with its files.
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
url | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
attach.setUrl('https://simple.instance.com:8443'); |
setUsername(username)
Use this method to set a user name username when connecting to a remote instance.
Info |
---|
A user, whose username is passed to the method, must have sufficient access rights to the source file. |
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
username | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
attach.setUsername('john.doe'); |
setPassword(password)
Use this method to set a password for a user whose security context is used when establishing a connection to a remote instance.
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
password | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
attach.setPassword('123456'); |
getAttachmentSN(sourceDocId, targetDocId)
To receice Use this method to receive an attachment from a remote instance, specify its DocumentID in that instance, and the DocumentID in the current . Specify its Document ID from the source instance and the Document ID of the record from the target instance where you need to add the copied attachemntsattachments. Use the setUrl(), setUsername(), and setPassword() methods described above to specify authorization properties.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
sourceDocId | String | Y | N |
targetDocId | String | Y | N |
Return:
Type | Description |
---|---|
String | If a file is received, the method returns the attachment ID from the cloud storage. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const attach = new SimpleAttachmentService(); attach.setUrl('https://source-now.instance.com:8443'); // A target instance. Add a real URL there before using this method. attach.setUsername('john.doe'); // Specify a real username before using this method. attach.setPassword('123456'); // Specify a real password before using this method. const docID = ss.getDocIdByIds('155931135900000084', '155931135900000001'); const attachId = attach.getAttachmentSN('f91d84fe7cff58d4db91f2e9c2dc02fb', docID); |
Table of Contents | ||||
---|---|---|---|---|
|