- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 03:19 AM - edited 03-31-2025 03:40 AM
Hi,
Am using below code to restrict file attachment type. The Portal and Non-Portal Code was working.
But as per ServiceNow suggestion it's not good to use DOM method. I did replacement with this line of code (this.g_form.getFormElementByClassName) for DOM in Portal script but it is not working.
So, please suggest alternatives to achieve my requirement.
Here is my code:-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 04:56 AM
if you want to restrict file type then better go with attachment variable type and use allowed_extension attributes to only allow particular file type
something like this
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 03:22 AM
@Ankur Bawiskar I saw one of your post
https://www.servicenow.com/community/itsm-forum/alternative-for-dom-manipulation-in-client-script/m-... and i used same method but it is allowing attachments without warning.
Like //var value = (this.g_form.getFormElementByClassName('get-attachment')[0].innerHTML).toLowerCase();
Is my way of declaration is correct, please suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 04:35 AM
You can use that script if required.
DOM is not recommended but we could find lot of OOB scripts using that.
Instead of that why not use attachment variable type and make it mandatory?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 04:48 AM
Agreed with you @Ankur Bawiskar but the script was designed long back. Client wana go with script.
So, looking for alternative for it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 04:56 AM
if you want to restrict file type then better go with attachment variable type and use allowed_extension attributes to only allow particular file type
something like this
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader