Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

List link to attachment

jcanuel
Kilo Explorer

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

1 ACCEPTED SOLUTION

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:


  1. var attachment = new GlideRecord('sys_attachment');  
  2. attachment.get('table_sys_id', current.sys_id);  
  3. 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)



  1. var attachment = new GlideRecord('sys_attachment');  
  2. attachment.get('table_sys_id', current.sys_id);  
  3. current.nameOfTheCreatedFiled= attachment.sys_id;  


Thank you.



Regards


View solution in original post

5 REPLIES 5

Thank you very much Edwin.


It works very well.


Have a nice day