Change attachment name by Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 11:58 PM
When a new record is added to the sys_attachment table, I want to upload this attachment to the AWS cloud, but I want to change the name of this attachment (add the time stamp) before uploading. What should I do?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 01:58 AM
Hi @ma kaiyue ,
You can create a before insert business rule on sys_attachment table as attached below,
Here i am checking for particular item you can change the code according to your requirement,
(function executeRule(current, previous /*null when async*/) {
var attachmentRitm = new GlideRecord('sc_req_item');
attachmentRitm.addQuery('sys_id', current.table_sys_id);
attachmentRitm.addQuery('item','Get user Detail');
attachmentRitm.query();
if(attachmentRitm.next()){
gs.info('inside if ');
var nameFile ="RITM Attachment for item Get user Detail";
var extensionName = current.getValue("file_name").split(".")[1];
current.file_name = nameFile + "." + extensionName;
}
})(current, previous);
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 03:49 AM
@ma kaiyue ,Thanks for marking my answer as helpful. If it helped you in any way please accept the solution so that it will be beneficial to the future readers with the same query.
Thanks,
Swathi