- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:00 AM
HI TEAM,
when to run-BEFORE
table-sys_attachment
I WANT THE BELOW BUSINESS TO RULE ON PARTICULAR CATALOG ITEM
/////Business rule///when 2 files are attached with same file name then there will be alert in below BR
(function executeRule(current, previous /*null when async*/) {
{
var gr = new GlideRecord("sys_attachment");
gr.addQuery('table_sys_id', current.table_sys_id);
gr.addQuery('table_name', current.table_name);
gr.addQuery('file_name', current.file_name);
gr.addQuery('content_type', current.content_type);
gr.addQuery('size_bytes', current.size_bytes);
gr.query();
if (gr.next()) {
{
current.setAbortAction(true);
gs.addInfoMessage("File already exist");
}}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:23 AM
you can not , business rule runs on table and catalog form is not a table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:08 AM
business rule does not execute on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:21 AM
Helo harshvardan,
Do you mean we cant run a business rule on particular catalog item or on all the catalog items.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:23 AM
you can not , business rule runs on table and catalog form is not a table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:21 AM
Hi Archie,
You have to wrap your code with in a condition. you can find pseudo code here, please be careful of performance impacts.
if(current.table_name == 'sc_req_item'){
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.table_sys_id);
gr.query();
if(gr.next()){
if(gr.cat_item == 'sys_id of your catalog item'){
// your code goes here
}
}
}
Please mark helpful or correct if you feel the answer is helpful or correct
Thanks
Ashok