attachments mandatory based on the Short Description of a Task
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 08:20 AM
attachments mandatory based on the Short Description of a Task and only for one task
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 09:58 AM
You can use either onSubmit Client script or BR>
function onSubmit() {
// Only apply to specific short description
if (g_form.getValue('short_description') !== 'Submit Design Document') {
return true;
}
// Check for attachments
var attachments = g_form.getAttachments();
if (!attachments || attachments.length === 0) {
g_form.showFieldMsg('short_description', 'Attachment is required for this task.', 'error');
return false;
}
return true;
}
create a Business Rule on the task table (or your specific task type like sc_task or pm_task)
....When: before
....Insert & Update:
....Condition: current.short_description == 'Submit Design Document'
(function executeRule(current, gS, gE, gR) {
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id', current.sys_id);
att.addQuery('table_name', current.getTableName());
att.query();
if (!att.hasNext()) {
gs.addErrorMessage('Attachment is required for this task.');
current.setAbortAction(true);
}
})(current, gs, g_event, g_request);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 11:19 AM
Hi @Gaurav Rathaur
Still not working
and I need one more condition based on yes or no varibale