Ui action button to upload an attachment of type only excel and csv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 05:24 AM - edited 03-03-2024 05:48 AM
I have created a UI action Bulk task once the user clicks on the button it prompts to select an attachment.
Now I want it to accept only Excel and csv files.
How can I achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 06:57 AM
Hi @Kishor O ,
Check this
https://www.servicenow.com/community/developer-forum/how-to-restrict-user-to-add-specific-file-exten...
Please hit helpful and accept this as a solution it it solved your problem.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 08:26 AM
Hi @Kishor O ,
you should avoid customizing the OOB UI macro. you should try using the business rule on sys_attachment.
Business Rule Condition and Script:
you can just avoid the attachment from getting attached to the record but infoMessage or alert is somewhat difficult
Condition: current.table_name == 'my_table' // add the tableName of your table here
Script:
var fileName = current.file_name.toString();
if(fileName.indexOf(".xls") != -1||fileName.indexOf(".csv") != -1){
gs.addInfoMessage("File should be xls(or) CSV file"); // but this was not coming while I tested, you can explore on this
current.setAbortAction(true);
}
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda