Sort Order of Attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2013 11:56 AM
I have a requested item being auto-generated from a quarterly email, and that email contains nearly 100 attachments. When the ticket is created, those attachments seem to be added arbitrarily, so I'm wondering if there is a mechanism available for updating the sort order of those attachments (preferably through a script). Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2013 11:34 AM
That's a good question!
It looks like attachments are loaded in insertion order, not by any magical sort order. There isn't a whole lot one can do to the sys_attachment table, either.
One option would be to set up a scheduled job that reads the sys_attachment table on a regular basis and sorts them the way you want them to be. I'm going to guess the updated column will play a role in which order it is displayed in so if you did a script to process all the attachments per each record and sort them in alphabetical order, and then trigger the update flag to update the records in that sorted order, you'll get what you want.
This would cause some overhead though, especially if you have 100,000s of attachments in your environment you're sorting.
I'm not sure how else this could be done though. You may be able to edit the script include that processes attachments but that's not something I'd want to "own" just because I touched it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2013 07:11 AM
Thanks for the response, Aaron! I appreciate your suggestions, though I agree with your hesitancy to add system overhead or take ownership of core system scripts. I'm mostly just glad to hear that I didn't miss something obvious!
For now, I'm going to try a different approach (and hopefully it won't add overhead or confusion of its own): I'm going to add the "Attachments" related list to the requested item form view. Users may not immediately understand why they can't delete files from this list (but can remove files from the "Manage Attachments" dialog box); they may also confuse themselves if they make edits to file names in one list (and don't immediately see those edits reflected in the other). However, they'll at least have the option to sort by whatever column they want (including file name).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2013 07:25 AM
I like your approach, it's simple 🙂 And it won't make life difficult for you later on.
This might be a noteworthy enhancement request to ServiceNow. I'm sure others would like a simple way to sort attachments on records.