How display "oldValue" in onchange client scripts. Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 11:43 PM
Here whenever state is change one to another . The previous state should show in " last status change"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 01:26 AM - edited 05-10-2023 01:27 AM
Hi,
The following works for me.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var oldVal = oldValue;
g_form.addInfoMessage(typeof oldValue);
g_form.addInfoMessage(oldValue);
g_form.setValue('u_old_state', oldVal); // my old state field name
}
That said:
- oldValue will always be the value of that field on form load, so if you are not saving after every state change the old value will not track the changes
- you get the Value (choice number), not the Display Value (e.g. In Progress) - you could do an ajax call to get it - or pass it on form load as a Display Business Rule scratchpad variable
If you are only wanting the old value after a save you could write the old value to the field using a business rule on update?
hth,matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 02:24 AM
I want display that "oldValue" in the filed of last status change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 03:02 AM
Is that for every change to the state field, or only after the state field has been changed and the record has been saved?
Also what is the Type of the field 'last status change', string? - or a reference to the sys_choice table?
r,matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 07:37 AM
String.