Ui action button to upload an attachment of type only excel and csv

Kishor O
Tera Sage

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?

KishorO_0-1709472157697.png

KishorO_1-1709472231400.png

 

 

 

2 REPLIES 2

M Ismail
Tera Guru

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

Sumanth16
Kilo Patron

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