Change the attachment fine name size

Black Coder
Tera Guru

Hi 

I changed the attachment file name size limit from 100 to 255 in sys_attachement table.Once again when I try to change to file name character size to 100, it is showing error as " Length change not allowed. The field 'File name' on table 'Attachment' contains existing data records (40) that exceed the new length of 100". But in this can what can I do??However i need to change the file name character limit to 100.

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

The only thing you can do is go into the 'sys_attachment' table and find all of the records where the file name is greater than 100 characters and change them to something less.  Here's a script you can run from 'Scripts -> Background' in your left nav to identify the problem records.

var att = new GlideRecord('sys_attachment');
att.query();
while (att.next()) {
    var name = att.file_name.toString();
    if (name.length > 100) {
        gs.print(att.file_name);
    }
}

View solution in original post

7 REPLIES 7

VigneshMC
Mega Sage

Find the existing records in  sys_attachment which has 'File name' length more than 100 and then reduce them to less than 100 , then try changing the field length

So do I have to make a query to fetch all the files which are having more than 100 character size?. in attachment table totally 450492 attachment available.how can i fetch ?

You can use mark's script to find the name or update the script to print out sys_id and truncate it .

Mark Stanger
Giga Sage

The only thing you can do is go into the 'sys_attachment' table and find all of the records where the file name is greater than 100 characters and change them to something less.  Here's a script you can run from 'Scripts -> Background' in your left nav to identify the problem records.

var att = new GlideRecord('sys_attachment');
att.query();
while (att.next()) {
    var name = att.file_name.toString();
    if (name.length > 100) {
        gs.print(att.file_name);
    }
}