How to check the Task close before closing the Change?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 01:16 PM
Hi All,
We need to close all the tasks where short description of Task contain the string "Dupicate Change Task"
Basically if the Tasks associated with the change are active and Short description = %Dupicate Change Task% then thease task should be closed then only system allow change to move to the next stage.
Need to do it using UI action.How to achive this.
Thanks in advance.
addQuery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 01:49 PM
Here is an example.
UI action checks if incident has active incident tasks:
UI Action:
Using getXMLWait() here since we want the use to wait for the answer, not clicking around like normally with getXML()
Script Include:
Only need to look at the checkTask the other one is for another community thread 😃
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 02:20 PM
Hi
I tried this in the UI Action after seeing your references.It looks ok. as giving the message to close the task.
var tsk = new GlideRecord('change_task');
tsk.addQuery('active',true);
tsk.addQuery('short_description','Duplicate Change Task');
tsk.query();
if(tsk.next())
{
alert('Close the Change Opened Task');
}
else
Hope this is the correct way.
Thanks..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 03:47 PM
Hi.
Step 1. Create a OnSubmit Client script
function onSubmit() {
if (g_form.getValue('state') == 0){
var ga = new GlideAjax('checkOpenChangetasks');
ga.addParam('sysparm_name','openChangetasks');
ga.addParam('sysparm_sid', g_form.getUniqueValue());
ga.getXMLWait(ga.getAnswer());
if (ga.getAnswer() == 'true') {
alert('Please complete all the Implementation Tasks');
g_tabs2List.setActive(0); // Task related list
return false;
}
}
}
Step 2. Create a Script include
- Name : checkOpenChangetasks
- Client callable : true
var checkOpenChangetasks = Class.create();
checkOpenChangetasks.prototype = Object.extendsObject(AbstractAjaxProcessor, {
openChangetasks : function() {
var changeSysID = this.getParameter('sysparm_sid');
var rec = new GlideRecord('change_task');
rec.addQuery('change_request' , changeSysID);
var qc1 = rec.addQuery('state', '-5');
qc1.addOrCondition('state', '1');
rec.query();
if (rec.next()) {
return true;
}
},
});
-', g_form.getUniqueV ', g_form.getUniqueV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2018 05:00 AM
Hi guys, thanks for this useful thread. Is it possible to modify this check so the CTASK look-up/check is that certain change tasks fields have been completed e.g. fields below are not NULL?
--Assignment group (assignment_group)
--Planned start (start_date)
--Planned end (end_date)
Bonus question...
Can you also check that 'Description' (description) field in CTASK is not a specific string e.g. "Describe the work", which is the default/'template' text that auto appears on the CTASK when it has been created by the workflow. I.e. check that it has been modified by a user and is different from the string/default text.
Many thanks.