- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2016 07:05 AM
I need to check if the incident has incident task or not:
If the incident has an inc task, the incident state should stay the same & If the incident does not have an inc task, I need to change the incident state to new.
this is what I've done :
I should mention that 'u_inc' is a field in the inc task table and it has the corresponding incident.
var rec=new GlideRecord('incident');
rec.addQuery('assigned_to',current.sys_id);
//rec.addQuery('assigned_to.active',false);
rec.addQuery('active',true);
rec.addQuery('state','!=',6);
rec.addQuery('state','!=',7);
rec.query();
while(rec.next())
{
rec.assigned_to = '';
rec.work_notes = "This ticket has been reassigned to the group because the original assignee is no longer active.";
rec.setWorkflow(false);
rec.autoSysFields(false);
var grIncidentTask = new GlideRecord('u_inc_task');
grIncidentTask.addQuery('u_inc',current.sys_id);
grIncidentTask.query();
if(grIncidentTask.getRowCount() == 0 )//If the incident does not have an inc task
{
rec.state = 1;//change the incident state to new
gs.addInfoMessage('incident does not have an inc task');
}
else if(grIncidentTask.getRowCount()!= 0 )//If the incident has an inc task
{
//the incident state should stay the same
gs.addInfoMessage('incident has an inc task');
}
rec.update();
}
MY problem: no matter if the incident has inc task or not it changes the state to new!! and I get this msg! --> gs.addInfoMessage('incident does not have an inc task');
I need in situations that inc has inc task , the state should stay the same
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2016 08:48 AM
Easy one
grIncidentTask.addQuery('u_inc',current.sys_id);
not current but rec I think
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2016 09:38 AM
yes, the current seems to be a "sys_user", right (it's a business rule on the sys_user table) and your rec seems to be your incidents