How to get Previous field value before Editing

Hi,All

How to get Previous field value before Editing and if someone try to edit the value in the field can we create validation to throw error. Please give me your suggestions

Hi Satish,

You can use the orig method to return the previous value. Like below.
this.orig().FieldName.

Thanks,
Girish S.

Hi Girish,

Using previous value can we write the validation to throw error when someone try to edit the field value

if(this.orig().FieldName != this.Name)
{
(Error msg)
}

What validation you want to throw?
Can you explain the functionality?

Thanks,
Girish S.

After inserting a value in the table field like “Name” field

for example I inserted “Sai” in the Name field

again if I want to change “Sai” to “Kiran” it should throw error saying your not authorized to edit the value.

Once entered the value it shouldn’t allow to edit the value by throwing error.

Why don’t you simply set the field with AllowEdit = No, instead of letting users set a new value and only then rejecting it?

If you insist on using your design, override validateField() on the table and return false (for the given field) if RecId != 0 (which means that the record was already inserted, i.e. it’s an update).

Yes, as Martin mentioned it’s easy to set the Allow edit to No on the table level.
So, it will be editable while creating since “Allow edit on create” will be Yes.

Thanks,
Girish S.

Thankyou Girish and MartinDrab

Both the suggestion really helped me
Thankyou.

Suggestions for capturing the previous field value before editing and implementing validation:

  1. Use JavaScript event listeners to track changes and store the previous value in a variable.
  2. When the user attempts to edit the field, compare the new value with the stored previous value.
  3. If the new value differs, display an error message using JavaScript or HTML to prevent incorrect changes.

sanjana_mohanty_sanj’s reply is completely wrong and irrelevant. He/she pays attention just to a few keywords and ignores the context.