- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2015 06:41 AM
Hi,
In the sys_attachment list, clicking an item in the file name column opens the "Save to" dialog box. Is it possible to reproduce that fonctionality in a custom table where all record contain one attached file ?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 09:31 AM
Hello Jacques,
I was doing more testing with this. At the end it wasn't as complicated as I though at first. You have two options (Option 2 is better from my point of view):
Option 1:
Modify the field that you created to be a Reference field to the sys_attachment table.
Change the advanced calculation to:
- var attachment = new GlideRecord('sys_attachment');
- attachment.get('table_sys_id', current.sys_id);
- current.nameOfTheCreatedFiled= attachment.sys_id;
Option 2:
Modify the field that you created to be a Reference field to the sys_attachment table.
Implement a business rule that runs before insert and before update (on your table) to populate the field that you created with the corresponding value:(Actually it would be the same code)
- var attachment = new GlideRecord('sys_attachment');
- attachment.get('table_sys_id', current.sys_id);
- current.nameOfTheCreatedFiled= attachment.sys_id;
Thank you.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2015 07:18 AM
I guess this functionality may be browser dependent, In chrome we will not get the "Save to" dialog box, where as in IE we can. .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2015 09:11 AM
Hi Jacques,
I think something like this should work. I'm not sure about how good performance will be though. Possibly there is another way to do it.
Create a custom URL field in your table. Select the Calculated checkbox. On the calculation field type this:
var attachment = new GlideRecord('sys_attachment');
attachment.get('table_sys_id', current.sys_id);
var link = '<a class="linked formlink" href="sys_attachment.do?sys_id=';
link+= attachment.sys_id;
link+= '">' + current.nameOfYourNameWithTheName + '</a>';
current.nameOfTheCreatedFiled= link;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 08:56 AM
Thank you Edwin,
It works fine in a form, but I need to make it work in a list (and it doesn't) !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2015 09:31 AM
Hello Jacques,
I was doing more testing with this. At the end it wasn't as complicated as I though at first. You have two options (Option 2 is better from my point of view):
Option 1:
Modify the field that you created to be a Reference field to the sys_attachment table.
Change the advanced calculation to:
- var attachment = new GlideRecord('sys_attachment');
- attachment.get('table_sys_id', current.sys_id);
- current.nameOfTheCreatedFiled= attachment.sys_id;
Option 2:
Modify the field that you created to be a Reference field to the sys_attachment table.
Implement a business rule that runs before insert and before update (on your table) to populate the field that you created with the corresponding value:(Actually it would be the same code)
- var attachment = new GlideRecord('sys_attachment');
- attachment.get('table_sys_id', current.sys_id);
- current.nameOfTheCreatedFiled= attachment.sys_id;
Thank you.
Regards
