
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 12:50 AM
Hi All,
I have a issue., we have a "status" choice field. We are giving a option to change the "status" to requester in ITIL view.
And we removed the options example : when the status is 'working in progress' we are removing all choice values but we are giving a 'close' choice option in every status for selecting. When requester selecting close option Reopen form button is visible.
i when i'm selecting reopen button i want to state should be previous state value.
How to do this scenario??
Regards,
Rakesh
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 02:16 AM
Ok here is the changes you need to do:
Write BR: OnBefore and condition State = Changes
(function executeRule(current, previous /*null when async*/) {
var prevalue = previous.state;
current.setValue('u_previous_state', prevalue);
})(current, previous);
After that write the UI Action code:
var preval = current.u_previous_state;
current.state = preval;
current.update();
action.setRedirectURL(current);
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 12:58 AM
Check this
you cannot get the previous value in UI ACtion
for more info below
https://community.servicenow.com/community?id=community_question&sys_id=376ec321dbdcdbc01dcaf3231f9619df
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 01:04 AM
Hi,
You can create one new field "Previous state" and store the value in it whenever state changes.
In UI Action, you can write the script:
current.state = current.u_previuos_state;
current.update;
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 01:19 AM
Hi shashikantyadav,
Thanks for your attention!!
yes i followed your suggestion and i created one field and i passed the state value when the state is changes.
but when i changed the state value into close the it passed the close value but i want to update it as previous value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 01:47 AM
Hi,
You will write code like this in ui action
current.state=current.u_previuos_state
current.update();