incidents created today & state is in new need to change to inprogress and assigned to me(Current user) by uisng fix script

Sushmitha9
Giga Contributor

incidents created today & state is in new need to change to inprogress and assigned to me(Current user) by uisng fix script

8 REPLIES 8

Saiganeshraja
Kilo Sage
Kilo Sage

var gr = new GlideRecord('incident');


gr.setWorkflow(false);
//gr.autoSysFields(false);
gr.query();


while (gr.next()) {
gr.state= '2';
gr.assigned_to = gs.getUserID();
gr.update();

}

Mark correct and helpful

Rahul Dev1
Giga Expert

Hi Sushmita,

You can try code below:

incidentChange();

function incidentChange(){

var gr=new GlideRecord('incident');

gr.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^state=1');

gr.setWorkflow(false);

gr.query();

while(gr.next()){

gr.state= 2;
gr.assigned_to = 'your sys_id';
gr.update();

}

}

Sushmitha9
Giga Contributor

hi rahul

On Change
- If caller is VIP then
category should be network
sub category should be IP address

 

_ if caller is NOT VIP then category and sub category should be empty(that is cat and sub cat should be none)

 

how to do this

Hi Sushmita

You can use the onChange client script on caller field as below:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

g_form.getReference('caller_id',validCaller);


}
function validCaller(callVip){
var call_vip=callVip.vip;

if(call_vip=='true'){

g_form.setValue('category','network');
g_form.setValue('subcategory','ip address');

}
else{
g_form.setValue('category','');
g_form.setValue('subcategory','');
}
}