- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 10:21 AM
Hi,
I need the list of managed document records where the length of the filename equals exactly 100 characters. So, I created a field "Length of file" on Revision table and captured the length of the file name in this field which is working fine as I used onload Client script. But I don't want to open each record and save it in order to appear on the list view.
I tried using fix script and before query business rule but none of them is working as expected.
Here is the code I used for Fix script
var gr = new GlideRecord("dms_document_revision");
var qry = 'attachment.file_nameISNOTEMPTY';
gr.addEncodedQuery(qry);
gr.query();
while (gr.next()) {
var field = gr.getDisplayValue('file_name').length;
if(field > 10)
{
gr.setValue("u_length_of_file", field);
}
gr.updateMultiple();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 12:13 PM
Try this...
var gr = new GlideRecord("dms_document_revision");
gr.addEncodedQuery('attachment.file_nameISNOTEMPTY');
gr.query();
while (gr.next()) {
var fieldLength = gr.attachment.getValue('file_name').length;
if (fieldLength > 10) {
gr.u_length_of_file = fieldLength;
}
gr.setWorkflow(false); // Do not run business rules
gr.autoSysFields(false); // Do not update system fields
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 10:36 AM
You're close, but I think something like this might work better.
var gr = new GlideRecord("dms_document_revision");
gr.addEncodedQuery('attachment.file_nameISNOTEMPTY');
gr.query();
while (gr.next()) {
var fieldLength = gr.attachment.file_name.length;
if (fieldLength > 10) {
gr.u_length_of_file = fieldLength;
}
gr.setWorkflow(false); // Do not run business rules
gr.autoSysFields(false); // Do not update system fields
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 11:32 AM
Hi Mark,
Thanks for your quick reply. This is fix script didn't work though. I tried both gr.update() and gr.update Mutliple(), none of them actually worked.
var gr = new GlideRecord("dms_document_revision");
gr.addEncodedQuery('attachment.file_nameISNOTEMPTY');
gr.query();
while (gr.next()) {
var fieldLength = gr.attachment.file_name.length;
if (fieldLength > 10) {
gr.u_length_of_file = fieldLength;
}
gr.setWorkflow(false); // Do not run business rules
gr.autoSysFields(false); // Do not update system fields
gr.updateMultiple();
}
Thanks,
Su

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 12:13 PM
Try this...
var gr = new GlideRecord("dms_document_revision");
gr.addEncodedQuery('attachment.file_nameISNOTEMPTY');
gr.query();
while (gr.next()) {
var fieldLength = gr.attachment.getValue('file_name').length;
if (fieldLength > 10) {
gr.u_length_of_file = fieldLength;
}
gr.setWorkflow(false); // Do not run business rules
gr.autoSysFields(false); // Do not update system fields
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 12:29 PM
Hi Mark,
Surprisingly, it worked for some of the records only. Most of them were not updated at all. That means we are close 🙂
Thanks again!
Su