Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jim Coyne
Kilo Patron

Note: I've written about this a few years ago (Displaying if a Record has an Attachment), but UI15 changed the way Field Styles in list views are shown.  This was carried over into UI16 as well.  I just thought it was time to add an updated article.

If you want to simply display in a list view when a record has an attachment, you can easily do it with a Field Style record:

find_real_file.png

The following Field Style will add a paperclip image to the Number field for all Task tables, as shown above for the Incident table:

Table: Task
Field name: Number
Value: javascript:current.hasAttachments()
Style:
background-image: url("u_attachment16x16.pngx");
background-repeat: no-repeat;
background-position: 98% 5px;
padding-right: 30px;

You can set the Table to whatever you need, but setting it on Task will then display the image for any sub-class table as well, but you can certainly target individual tables instead.  You would just need to add a Field Style for each of those tables.

Next thing you need to do is add the image you want to use by clicking on the "System UI \ Images" Module and creating a new record (Upload one or more images).  I've attached the paperclip image used in the screenshot above to this post, if you don't already have an image you want to use.  I grabbed it from the button shown on form views to attach a file to the record, derived from the Retina icons used in the platform.

find_real_file.png

The issue with UI15/16 is any Field Style is now shown to the left of the data in the column.  This causes a staggered look to the Number column as shown in the first screenshot.  We can fix that by adding another Field Style record with the following details:

Table: Task
Field name: Number
Value: javascript:!current.hasAttachments()
Style:
background-image: url("u_blank16x16.pngx");
background-repeat: no-repeat;
background-position: 98% 5px;
padding-right: 30px;

Notice the "!" in front of the word "current" in the Value field.  This will return true for all records that do NOT have an attachment.  Using an image that is blank (transparent background without anything else) and the same size as the attachment image, will then push the number over the same amount as the paperclip image.  You'll need to add another image for the style:

find_real_file.png

Now you'll end up with a better looking list view:

find_real_file.png

So basically, you need 2 Field Style records - one for records with an attachment and another for those without an attachment.

Attached below are the 2 images and 2 Field Style records needed to get the above look.  Try it out in your personal dev instance.

2 Comments