if state is inprogress then shortdescrition should applied other wise it should Abort

praveensnow9984
Tera Contributor

if state is inprogress then shortdescrition should applied other wise it should Abort the action?

var gr=new GlideRecord('incident');
gr.addQuery('number','INC0000059');
gr.query();
if(gr.next())
{
    gr.state='2';
    gr.short_description="if condition is applied1";
    }
    else
    {
    current.setAbortAction(true);
   // gr.setWorkflow(false);
    //gr.autoSysFields(false);
    gr.update();
    }
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@praveensnow9984 

what's your actual business requirement?

what script did you share? where did you write it?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Nishant8
Giga Sage

Hello @praveensnow9984, just looking at your script, I'm wondering about your actual use case. Nevertheless, i think below modified script should help you update short description and abort otherwise

var gr=new GlideRecord('incident');
gr.addQuery('number','INC0000059');
gr.query();
if( gr.next() ){	
	if ( gr.state == 2 ){
    	gr.short_description='if condition is applied1';
		gr.update();
	}
	else
		current.setAbortAction(true);
}

 

Regards,

Nishant