Calculate specific table attachments size from sys_attachment table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 11:44 AM
Hi,
I need to calculate total attachments size of hr table from sys_attachment table ? Can anyone help me with the script
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name','hr_case');
gr.Query();
var totalSize=0;
while(gr.next()) {
totalSize=parseInt(gr.size_bytes);
}
gs.print(totalSize);
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 11:54 AM
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 11:56 AM
Please Refer below links:
Thanks,
Rajashekhar Mushke
Community Leader -18
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 12:05 PM
It is writing some lengthy number and it is very hard to convert into kb even.I want function to convert into kb in the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 11:28 PM
Adding 'parseInt' to avoid var CONCATENATION instead of SUM
Adding conversion to MB instead of BYTES
(tested in Madrid)
---------------------------------------------------------------------------------------------------
findAttachmentsSize();
function findAttachmentsSize(){
var size_compressed = 0;
var size_bytes = 0;
grAttachment = new GlideRecord('sys_attachment');
grAttachment.query();
gs.print('Total Number of Attachments: ' + grAttachment.getRowCount());
while (grAttachment.next()){
size_compressed += parseInt(grAttachment.size_compressed);
size_bytes += parseInt(grAttachment.size_bytes);
}
gs.print('Total Size Compressed (MB): ' + parseInt(size_compressed / 1024 / 1024));
gs.print('Total Size Bytes (MB): ' + parseInt(size_bytes / 1024 / 1024));
}
---------------------------------------------------------------------------------------------------