how to get field previous value in a UI action (server side)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 04:29 AM
I have a UI Action executing on server.
I need the PREVIOUS value of a field because I need to know if the value has changed.
(I do NOT want to use a BR, I want the UI Action).
Is there a way to do this?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 05:23 AM
Hi,
I think what you are looking for is given here:
https://community.servicenow.com/community?id=community_question&sys_id=68b407e9dbd8dbc01dcaf3231f961922
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 05:26 AM
nope. don't want g_form (not on client)
i know i have access to "previous" in a br but does not seem like i do in a ui action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 05:52 AM
Hi,
Unfortunately you cannot call 'previous' object inside the UI Action like Business Rule. Either you have to achieve the same like above or opt for a conventional way to create a new field and store the previous field value to that only. Obviously, it is not recommended until unless you have a strong business requirement.
But if you are trying to monitor whether any field value on the form got change you can use g_form.modified in side the client side in your UI Action. Also, you may call GlideScriptRecordUtil class to check wheather you may leverage the same. For reference: Checking for Modified or Changed Fields in Script.
I hope this helps.Please mark correct/helpful based on impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 05:31 AM
Take a look at UI Action like create normal change. It looks like it is setup like a business rule where the first line is (function(current, previous, gs, action){. Since it is server side scripting you should be able to get the previous value unlike client script which always return null.