
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
//See if any closure records exist
//--------------------------------------------------------------
var ct = new GlideRecord('u_ks_task_closure');
ct.query();
while(ct.next()){
// If closure record end date is past today then add task record
//---------------------------------------------------------------
if(new Date().getTime() > new Date(ct.u_closure_date.substring(0,4), (ct.u_closure_date.substring(5,7)-1), ct.u_closure_date.substring(8,10)).getTime()){
//Find RITM record, change it's status to in progress and add a task
//---------------------------------------------------------------
var ritm = new GlideRecord('sc_req_item');
if(ritm.get('number',ct.u_ritm_number)){
//If ritm wasn't rejected update it's status
//-----------------------------------------
if(ritm.approval != 'rejected'){
ritm.active = true;
ritm.state = 2;
ritm.stage = "executing"
ritm.comments = "New task added to remove access since end date ("+ct.u_closure_date+") has passed.";
ritm.update();
}else{
continue;
}
}
//Get assignment group for this particular task/RITM
//---------------------------------------------------------------
var assignGroup = "";
var group = new GlideRecord('u_ks_task_closure_helper_table');
if(group.get('u_catalog_item',ritm.cat_item.sys_id)){
assignGroup = group.u_task_closure_group.sys_id;
}
// Create new Task record and tie it to the parent ritm record
//---------------------------------------------------------------
var newTask = new GlideRecord('sc_task');
newTask.initialize();
newTask.short_description = "REMOVE ACCESS: '"+ritm.cat_item.name+"' for "+ritm.request.requested_for.name;
newTask.description = "Access to this resource has expired and needs to be removed";
newTask.assignment_group = assignGroup;//fulfillment group from helper table
newTask.request_item = ritm.sys_id;//sys id of parent ritm
newTask.parent = ritm.sys_id;//sys id of parent ritm
newTask.insert();
// Delete record from closure table
//---------------------------------------------------------------
ct.deleteRecord();
}//End if closure end date is past today
}//end loop
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.