Change and Change Task

jithinajay
Kilo Contributor

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

15 REPLIES 15

Thanks Suraj for the inputs..



I have achieved the same using before business Rule.


I don't have to write two Seperate business Rules for this.



Thanks for the Suggestions.


Hi Jithin,



Can you mark as answered and close the question.




-Suraj


Hi Suraj,



I have similar requirement but a more generic one.     I just need to ensure that change request can't be closed if there are open change tasks.


I saw your post, and tried the above business rule, it does not seem to work unfortunately



this is what I had as 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);


  target.query();



  if(target.hasNext()){


// check if state of change request changes to Closed


  if ((current.state == -15) || (current.state == -16)){


  gs.addInfoMessage("You have open tasks which must be completed before this record can be closed");


  current.setAbortAction(true);


  }


  }


}



--------------Please advise if I have typed something incorrectly--------------



I wasn't sure about what to put in this line. Was is before and after state?


  if ((current.state == -15) || (current.state == -16)){



Please assist. thanks so much,


Hello Peggy,





I would like to say that I tested the Business Rule of Sujar by covering your scenario:
- having one active Change Request which has one Open task in it;



I may confirm that the Business Rule in the way it was originally pasted above will not work for it, due to the fact that it does not cover your exact scenario.
I noticed that you made a change in the "check if state of change request changes to Closed" line of code. Even with this change the BR will not work for you.



In my opinion, the problem which prevents the BR to fulfill your scenario comes from this line of code:
if ((current.state == 4) || (current.state == 5)){ -> In order to work the '5' state value should be changed to '3' (Closed).
Once it is changed -> then the following will happen when you try to close a Change Request which has an Open task in it:


Change1.png



In order to fix the BR of yours, you need to have the proper State values on your disposal.
To obtain them please do the following -> right - click the State field in a Change Request form and then select Configure Dictionary.


There, in the Choices list you will see the values that respond for each state. Select the proper ones that cover your scenario and your issue will be solved.
In my case, I used that line of code:   "if ((current.state == 4) || (current.state == 3)){" or in other words: 4: Canceled & 3: Closed.
As my case is the same as yours, Peggy - I would say that by using these values you will get rid of your problem.




Hope this information will be helpful to you.




Best Regards,


Georgi Mavrodiev



IT Consultant


Do IT Wise



You may visit us in our Web Site: www.doitwise.com


Hi Georgi,



Thanks for your comprehensive reply.



In my company, we have 2 change statuses - Completed and Closed.   The reason why we have completed and closed is that completed is more like resolved and closed is when the change manager has verified that the change can be closed. So the workflow is new > review > pending approval > pending CAB > scheduled > completed > closed.


In the dictionary:


Completed = -16


Closed = 7



What I want to do is not allow users to move the change request to completed if there are open change tasks.   And give them an error message "to close tasks".



You mentioned to amend   line of code:   "if ((current.state == 4) || (current.state == 3)){" or in other words: 4: Canceled & 3: Closed.


I tried changing to:


"if ((current.state == -16) || (current.state == 7)){" or in other words: -16: Completed & 7: Closed.



But still didn't work.   What else should I be looking for to fix this BR?



I'm a little lost.



Regards,


Peggy