State is not setting to previous value in before update BR?

Saranya K
Tera Contributor

Hi all,

When change task move to close state   if there is no attachment change task abort the action  and set state and closed code to previous value.

 

I have written Before update BR on change_task table:

condition state change to closed.

 

only the state is not set to previous value

 

can anyone helpme on this.

 

var attach = new GlideRecord('sys_attachment');
    attach.addQuery('table_name', 'change_task');
    attach.addQuery('table_sys_id', current.sys_id);
    attach.query();
    if (!attach.next()) {
 
        gs.addErrorMessage("Kindly attach evidence of successful completion of the CTASK (email comms/ Screenshots)");
current.state = previous.state;
        current.close_code = previous.close_code;
current.setAbortAction(true);
}
 
 
12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

@Saranya K 

so it's aborting but not setting the previous value?

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

Hi @Ankur Bawiskar ,

 

Yes it's aborting but not setting the state value to previous. how to fix it

Thanks

@Saranya K 

user will have to refresh to see the old value

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

Hi @Ankur Bawiskar ,

 

without user refresh i want to achieve it is there any auto refresh in servicenow

Thanks,