Add date as prefix to attachments
- Sebastian Haugland
- Posts: 43
- Joined: Fri Sep 19, 2014
- Contact:
Hi
When a task has several attachment it is difficult to find the latest attachment and one of "my users" asked if I could add the upload date in front of the filename that is uploaded to the task.
I tried to change the attachment field but that did not work, any suggestions? (do I have to change the filename after saving the file?)
When a task has several attachment it is difficult to find the latest attachment and one of "my users" asked if I could add the upload date in front of the filename that is uploaded to the task.
I tried to change the attachment field but that did not work, any suggestions? (do I have to change the filename after saving the file?)
Hi,
Your course of action would be:
1. Create a multi-line plain text field 'UploadedAttachmentsList'
2. Paste the following JS code onto the form:
3. Add the UploadedAttachmentsList field onto the form and hide it with the following CSS (the style attribute):
What all this will do is use a hidden text field to log the order of files added and add 'most recent' to the first attachment option on the list.
You can advance this piece of functionality by removing deleted files (in the onsubmit handler), adding date and time to the list.
You also need to test this feature thoroughly as it's not intended to be a complete solution, but only a guide to one.
Your course of action would be:
1. Create a multi-line plain text field 'UploadedAttachmentsList'
2. Paste the following JS code onto the form:
Code: Select all
fd.onsubmit(function(){
if (fd.field('Attachments').control()._el().find('tr[id^="attachRow"]').length) {
var attachments = '';
fd.field('Attachments').control()._el().find('tr[id^="attachRow"]').each(function(i, e){
attachments += $(e).find('span').text().split('\\').slice(-1)[0] + '\n';
});
fd.field('UploadedAttachmentsList').value(fd.field('UploadedAttachmentsList').value() + attachments);
}
return true;
});
var attachments = fd.field('UploadedAttachmentsList').value().split('\n');
var found = false;
for (var i = attachments.length - 1; i >= 0 && !found; i --) {
fd.field('Attachments').control()._el().find('tr span a').each(function(){
if ($(this).text().trim() === attachments[i].trim()) {
$(this).text('most recent ' + $(this).text());
found = true;
return false;
}
});
}
Code: Select all
display:none;
You can advance this piece of functionality by removing deleted files (in the onsubmit handler), adding date and time to the list.
You also need to test this feature thoroughly as it's not intended to be a complete solution, but only a guide to one.
- Sebastian Haugland
- Posts: 43
- Joined: Fri Sep 19, 2014
- Contact:
with "Paste the following JS code onto the form:" do you mean under Javasript? ie the red button?
or as a html field?
or as a html field?
-
- Information
-
Who is online
Users browsing this forum: No registered users and 7 guests