current.setAbortAction(true) but capture a fields value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2013 07:42 AM
Hello ServiceNow forums,
I have added a business rule to our instance.
The purpose of it is to check that problem tasks are closed before the problem.
var rec = new GlideRecord('problem_task');
rec.addQuery('problem', current.sys_id);
rec.addQuery('active', true);
rec.query();
//If any of the tasks are active abort the submission
if(rec.hasNext()){
gs.addInfoMessage('Please close Problem Tasks first');
current.setAbortAction(true);
}
This code works fine but the problem I have is.
1. A user enters resolution information and then tries to close a problem with open tasks.
2. A message is shown saying they need to close tasks first
3. The user goes into a open task and closes it.
4. The user goes back to the problem record and has lost their resolution information.
Under these circumstances I would like what the user puts into the resolution field to be transferred into the work_notes.
Any help would be appreciated!
Thanks,
Iain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2013 10:34 AM
Hi,
I am struggling even with this one.
I am trying to use this code
var rec = new GlideRecord('problem_task');
rec.addQuery('problem', current.sys_id);
rec.addQuery('active', true);
rec.query();
//If any of the tasks are active abort the submission
if(rec.hasNext()){
gs.addInfoMessage('Please close Problem Tasks first');
current.problem_state = 1;
}
To set the state back to open if there are tasks. This only works if the state is not "Open" prior to the business rule running.
For example if the state is "Pending Change" and I try and close the problem with open tasks it gives me the message and sets the problem back to "Open". However if its already open it stays closed.
I noticed there are 2 other out of the box business rules that might have something to do with this
Copy State to Problem State
// Helps keep state and problem_state synchronized
current.problem_state = current.state;
and
// Helps keep state and problem_state synchronized
current.state = current.problem_state;
but I don't know how to fix this.
Please help?
Thanks,
Iain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2013 10:48 AM
Try setting both fields to 1. state *and* problem_state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2013 12:21 PM
Perfect!,
Thanks a lot.