How to get old value in On Submit Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hello All,
I got a requirement where we have list of Risk fields on Change Form based on those questions Risk has to be calculated and it's getting calculated.
Now the problem is I need to show alert message to the user when user updates the related Risk fields and saves the form, I have written the below On Submit client script and it's showing the message but I need to show the message only when user updates the Risk Assessment values from one value to other but not on when user updates from Empty to Something(i.e., on Initial update) so please guide me on checking if the previous is empty or not.
On Submit Client Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
The easy way is to do this onChange instead of onSubmit, as the oldValue object is then made available. Another approach is to create a Display Business Rule on the table, writing the value when the record loads to the scratchpad. The script for this is simply
(function executeRule(current, previous /*null when async*/ ) {
g_scratchpad.shortdescription = current.request_item.short_description;
})(current, previous);
or you can get more advanced if needed. In the Client Script then, you can use something like
var oldvalue = g_scratchpad.shortdescription;
to access this field value as of when the form loaded.