Custom "Attachment Dialog"

ipt_meu
Kilo Contributor

Hi all,

I have to modify the default upload to the "sys_attachment" table in ServiceNow. We're using scoped apps and I don't want to affect other apps which are using the default upload dialog as well. The upload dialog is written in Jelly (UI Page). Is there a way to create a second upload function or UI Page with some custom changes in the dialog box? (I need a field: documenttyp - and I need it in the DIALOG (must)). Or are there any best practices/ideas? I tried to copy the default attachment UI Page but when I call it via GlideDialogWindow the dialogbox is empty.

Thanks in advance

1 ACCEPTED SOLUTION

Hi Max,



Loading attachment through GlideDialogWindow here is the script



var sysId = g_form.getUniqueValue(); // sysId of the record to which attachment is to be added


var tableName = 'incident'; // table name give as per your table name


var dialog = new GlideDialogWindow("attachment2");


dialog.setTitle("Add Attachment");


dialog.setPreference("target_sys_id",sysId);


dialog.setPreference("target_table",tableName);


dialog.render();



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Max,



So you need your own custom attachment ui page which you want to call from where?


Can you explain more on this and also share the code snippet which is causing issue to you.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hey Ankur



I just cloned the ui page "attachment" (from the Jakarta instance) to "attachment2". Then I added a button to call this "attachment2" ui page with the following code:


var dialog = new GlideDialogWindow("attachment2");



But the dialog is empty.



Are there any other solutions to add attachments with a custom dialog?


Hi Max,



Loading attachment through GlideDialogWindow here is the script



var sysId = g_form.getUniqueValue(); // sysId of the record to which attachment is to be added


var tableName = 'incident'; // table name give as per your table name


var dialog = new GlideDialogWindow("attachment2");


dialog.setTitle("Add Attachment");


dialog.setPreference("target_sys_id",sysId);


dialog.setPreference("target_table",tableName);


dialog.render();



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi can you please explain me where I have to put this code and how to cal this.. I have just cloned already available attachment code and renamed. I have to add that new attachment window to change request form. Can you please guide me?