Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:08 AM
I have done a third party integration. They are sending a URL which, I store in a URL field. Now, how can I download and attach the file in existing record?
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:11 AM
You can write an async/update BR and use the following script-
(function executeRule(current, previous /*null when async*/ ) {
var endpointURL = current.u_url;
var attachmentName = "Attachment Name" + current.number + ".mp4";
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('GET');
request.setEndpoint(endpointURL);
request.saveResponseBodyAsAttachment('Table Name', current.sys_id, attachmentName);
var response = request.execute();
if (response.getStatusCode() == 200) {
// Get the response body (file content)
var responseBody = response.getBody();
} else {
gs.error("Failed to retrieve file. HTTP Status Code: " + response.getStatusCode());
}
})(current, previous);
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:11 AM
You can write an async/update BR and use the following script-
(function executeRule(current, previous /*null when async*/ ) {
var endpointURL = current.u_url;
var attachmentName = "Attachment Name" + current.number + ".mp4";
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('GET');
request.setEndpoint(endpointURL);
request.saveResponseBodyAsAttachment('Table Name', current.sys_id, attachmentName);
var response = request.execute();
if (response.getStatusCode() == 200) {
// Get the response body (file content)
var responseBody = response.getBody();
} else {
gs.error("Failed to retrieve file. HTTP Status Code: " + response.getStatusCode());
}
})(current, previous);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:12 AM
It worked! Thanks for quick support.