- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 12:29 AM
Hello all,
I have a requirement for making attachment mandatory on sc_task, but i have multiple catalog task and i want to make attachment mandatory on a particular task. please let me know how we can achieve it.
Thanks in Advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 03:35 AM
Hello VickyRai1,
Please use the below code in Business Rule
(function executeRule(current, previous /*null when async*/) {
// gs.addInfoMessage("Result:"+current.hasAttachments());
if(current.hasAttachments() != true){
gs.addInfoMessage("Please add an attachment");
current.setAbortAction(true);
}}
)(current, previous);
And set When to run as before , update.
use condition as requested item.item is "catalog item name".
and state changes to closed complete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 12:42 AM
Can you please elaborate you requirement on what criteria you want attachment should be mandatory on sctask.
Regards,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 12:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 12:44 AM - edited 02-14-2024 01:03 AM
Hi @VickyRai1,
You can create before update Business rule on sc_task table with the below script, please mention the condition if required,
(function executeRule(current, previous /*null when async*/) {
var att = new GlideAggregate('sys_attachment');
att.addAggregate('COUNT');
att.addQuery('table_name', current.getTableName());
att.addQuery('table_sys_id', current.sys_id);
att.query();
var count = 0;
if (att.next()) {
count = att.getAggregate('COUNT');
if (count<1) {
gs.addInfoMessage("Attachment is Mandatory");
current.setAbortAction(true);
}
}
})(current, previous);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 03:35 AM
Hello VickyRai1,
Please use the below code in Business Rule
(function executeRule(current, previous /*null when async*/) {
// gs.addInfoMessage("Result:"+current.hasAttachments());
if(current.hasAttachments() != true){
gs.addInfoMessage("Please add an attachment");
current.setAbortAction(true);
}}
)(current, previous);
And set When to run as before , update.
use condition as requested item.item is "catalog item name".
and state changes to closed complete.