Change and Change Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2015 08:33 AM
Hello All,
I have a requirement which is related to Change and Change task
Scenario:
Considering an example:
I have a change request and I have 8 associated CTASKS as well. When I "Close Complete" the change request some 4 out of 8 Open CTASKS should get " Close Skipped".
If the change request has remaining 4 open CTASKS, it shouldn't allow the change to get close and I am expecting a pop up message stating that "Open CTASKS are present and you can't close the change)
Is this possible? If yes how can I achieve this?
Your response will be very much appreciated.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2015 09:34 AM
Jithin,
You can have a business rule which checks for this and if the condition is not met, then you can abort the action and display the error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2015 10:41 AM
Hello Jithin,
try the below business rule
Table: Change request
When: Before (insert and Update)
Script:
function onBefore(current, previous) {
var target = new GlideRecord('change_task');
target.addQuery('change_request', current.sys_id);
//search for open Change tasks - select the state from change task which you need to query
target.addQuery('state', 1).addOrCondition('state', 2).addOrCondition('state', -5);
target.query();
if(target.hasNext()){
// check if state of change request changes to Closed
if ((current.state == 4) || (current.state == 5)){
gs.addInfoMessage("You have open tasks which must be completed before this record can be closed");
current.setAbortAction(true);
}
}
}
Let us know if this helped
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2015 03:00 AM
Hi Suraj,
Thanks for the response.
I guess this script is checking for all the open CTASKS and then preventing the change from getting closed.
You are checking the status of CTASK.
But I am looking for CTASK Type.
I will give you an example:
I have CTASKS having type mentioned below:
- Configuration
- Deployment
- Customer Notification
- Pre-Release Validation
What I am looking for is if a Change has a related CTASK which is having Type "Configuration or Deployment" It should prevent the change from getting closed and should show the pop up You can't close the change until CTASK is closed.
But if a Change has CTASK Type "Customer Notification" and "Pre Release Validation" it should allow change to get closed
even though those two CTASKS are open and after closing the change those two CTASKS Should get skipped.
I hope this clarifies.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2015 10:10 AM
Hi Jithin,
In the above script you can add a query as below (this will only query where type is configuration and deployment
target.addQuery('type', "Configuration").addOrCondition('type', "Deployment"); // check for the correct values for Configuration and deployment
for the 2nd part, you can write a 2nd business rule which will check for change task type as "Customer Notification" and "Pre Release Validation" and will set the status to skipped when change request is set to Closed status.
Let me know if this helped
-Suraj