CTASK Attachment mandatory
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 08:27 AM
Hi all,
I created the below script for Change task for Attachment Mandatory and but
IN THE emergency change short descrption is impementation task , in code i wrote implementation
(function executeRule(current, previous /*null when async*/ ) {
var chg = new GlideRecord("change_request");
chg.addQuery('sys_id',current.change_request);
chg.query();
if(chg.next())
{
gs.log('type'+chg.type);
var change_type= chg.type;
}
if (((current.short_description == "Post implementation testing") && (change_type == 'normal' || change_type == 'standard')) || (current.short_description == 'implementation' && (change_type == 'emergency'))) {
var attachmentGR = new GlideAggregate('sys_attachment');
attachmentGR.addAggregate('COUNT');
attachmentGR.addQuery('table_name', 'change_task'); // Change Task table
attachmentGR.addQuery('table_sys_id',current.sys_id); // Current Change Task record
attachmentGR.query();
if (attachmentGR.next()) {
var attachcount = attachmentGR.getAggregate('COUNT');
}
}
if(attachcount == 0)
{
gs.addErrorMessage('The attachment of the sanity implementation test result is mandatory before closing the post-implementation testing CTASK');
current.setAbortAction(true);
current.state = previous.state;
current.setRedirectURL(current);
}
})(current, previous);
any one can help on this code
Labels:
- Labels:
-
Change Management
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 09:28 AM
It's a string compare, so 'implementation' is not equal to 'implementation task' so your condition will meet here. Let's say if you used a condition 'contains' then it might have worked...
I hope this helps...
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....