How display "oldValue" in onchange client scripts. Please advise.

AJAYKUMAR G
Tera Contributor

Here whenever state is change one to another . The previous state should show in " lasIMG_20230510_120849_copy_1152x648.jpgIMG_20230510_121208_copy_1152x648.jpgt status change"  

5 REPLIES 5

Matt102
Giga Guru

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

I want display that "oldValue" in the filed of  last status change.

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

String.