
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 12:50 AM
Hi all,
I have a 'File Attachment' type field on Demand table. Now, on the form, this field is dependent on another field.
If the choice option for 'Need attachment?' field is selected as 'Yes', the 'File Attachment' field is visible and a file can be attached to the field, but onChange of 'Need attachment?' field choice to 'No', 'File Attachment' field should disappear as well as the attachment should be removed.
How to remove the attachment on 'File Attachment' field in onChange client script of 'Need attachment?' field ??
Thanks all!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 11:38 PM
Hi Ankur,
Along with not displaying the 'File Attachment' field, I am willing to remove the attached file as well, so that on re-display on the field, it comes blank.
The solution found : GlideAjax from Client Script, in script include, GlideRecord sys_attachment table and removed the latest file related to that table record. Though this is not a completely accurate procedure, but a feasible workaround.
Hope others can put in better solution!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 12:51 AM
Hi
Instead of client script try it with Ui Policy.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 01:52 AM
Still didn't work.
Issues with 'File Attachment' field, it seems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 02:41 AM
Hi Pranshu,
It seems that field type is having an issue in Madrid some patch
UI policies doesn't seem to work on that type of field
the below line of code works for me in
g_form.setDisplay('u_sample_file', false);
Can you share your script here?
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 11:38 PM
Hi Ankur,
Along with not displaying the 'File Attachment' field, I am willing to remove the attached file as well, so that on re-display on the field, it comes blank.
The solution found : GlideAjax from Client Script, in script include, GlideRecord sys_attachment table and removed the latest file related to that table record. Though this is not a completely accurate procedure, but a feasible workaround.
Hope others can put in better solution!