The CreatorCon Call for Content is officially open! Get started here.

How to set a previous value of a field through Scheduled jobs

Mishu
Tera Expert

I am running a job to check for a state value that is on On Hold and the date given in a particular field matched todays date, then set the state field back to the previous value (i.e. state value which was before On Hold).

Please suggest.

1 ACCEPTED SOLUTION

Hi,

A simple solution would be to create custom field 'Previous state' on your table and set the value of this field using BR on State change.

A BR would be:

When - Before Insert/Update (condition = state changes)

use below line in script part 

current.u_previous_state = previous.state;

 

This will track the previous state and you can use it in your scheduled job.

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

8 REPLIES 8

Mishu
Tera Expert

@Anil Lande - Could you please suggest

Hi,

A simple solution would be to create custom field 'Previous state' on your table and set the value of this field using BR on State change.

A BR would be:

When - Before Insert/Update (condition = state changes)

use below line in script part 

current.u_previous_state = previous.state;

 

This will track the previous state and you can use it in your scheduled job.

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

@Anil Lande -- Ok, but we can't make it happen directly by scheduled job or flow designer to fetch the previous value?

Hi,

All records in ServiceNow tables store the current value, previous values available in BR only for the specific transaction. 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande