- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 12:50 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 04:00 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 12:55 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 01:00 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 01:38 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 01:48 PM
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.