- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2014 02:39 AM
Hi,
I would like to see of the attachment name is 'myfile.xls'. Here I have to check two things
1. File should be in excel 2007 format
2. file name should be 'myfile'
I can not edit 'attachment' form as it applies to every module. I am thinking to write a business rule. How can I achieve above objectives ?
Any one worked on the same stuff before?
Thanks,
Abhijeet
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2014 09:27 PM
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
if(gr.next()){//use `while` if dealing with multiple attachments
if(gr.getValue('file_name').indexOf('xlsx') != -1 && gr.getValue('file_name').indexOf('myfile') != -1){//meaning if you find a file with xls extension
//do something
}
}
You could even check for content type, but until and unless you are doing this check for an integration you should be fine in majority of cases.
Or, even better if you know the name and extension of the file is same meaning the name of the file and the extension is myfile.xlsx then you could just do that check in the `if` using the |indexOf| method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2014 02:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2014 05:35 AM
Hi Mahira,
I am not sure about the code that I need to write in Business rule. I cant figure out how to get the file name that is being attached to the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2014 09:15 PM
HI Abhijeet.,
Is the requirement to check if the user has attached an 2007 excel file?
If it is not a 2007 excel sheet what do you want to do?
Regards,
Mahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2014 09:48 PM
Hi Mahira,
User should be allowed to attach excel 2007 file only. If user attaches any other file format ( To that table only ) then it should not submit the form. If the file format is different then it will throw alert to change file.