The CreatorCon Call for Content is officially open! Get started here.

Business Rule - Check if a Change Request has a Change Task

traviswarren
Kilo Expert

Hello all,

I have a requirement where a change request must have at least one change task before setting the state to requested.   Below is where I stand at the moment.

condition: current.state.changesTo(9)

  var tr = new GlideRecord('change_task');

  tr.addQuery('change_request', current.change_request);

  tr.query();

  if(!tr.next())

  {

  gs.addErrorMessage("Please create a Change Task");

  current.setAbortAction(true);

  }

thanks in advance.

1 ACCEPTED SOLUTION

Very minor change and now its working. Still should have worked before but overall happy that its working now.




var ctask = new GlideRecord('change_task');


ctask.addQuery('change_request', current.sys_id);


ctask.query();


if(!ctask.next())


{


  gs.addErrorMessage("Please create a Change Task");


  current.setAbortAction(true);


}




Thanks!


View solution in original post

6 REPLIES 6

casey_stinnett
Giga Expert

Travis,



I could look into this more if you are more specific as to what the error is and what your question is.   What is your question?


Hello Casey, I am attempting to not allow users submit change-requests to "Requested" if they do not create a change_task. If so, it should display an error message and abort.


Sorry, I guess I should have been more clear. I got from your statement and your code what you are attempting to do and I don't see any immediate issues with your code. Also, you didn't tell us what your question is.



What is the error that you are experiencing that you would like help with?


At the moment the business rule is not triggering.   The business rule should trigger if it cannot find at least one change_task per change_request. Its a check to verify that at least one Change Task has been created for the Change_request when the request changes to the state "Requested".   When querying the change_task table and it does not find a correspond change_request sys ID to the current record, it should warn the user and abort the record.   At the time the business rule is not taking that action.