How to detect modified fields before save and conditionally block save ?

Hi Community,

I am working with Creatio Freedom UI (8.x) and I have the following validation requirement.

Scenario

I have two sets of fields:

  • Set A → A group of key fields (for example: Field1, Field2, Field3)
  • Set B → A group of  fields (for example: ApprovalReason, Comments)

Requirement

  1. If any field from Set A is modified, then:
    • I need to check whether all fields in Set B are filled.
    • If any field in Set B is empty → block save and show validation message.
  2. If the user modifies fields that are NOT part of Set A:
    • Save should be allowed normally.

My Questions

  1. In Freedom UI, is there any built-in attribute that stores the list of changed/modified fields before saving the record?
  2. If not, what is the recommended approach to detect whether specific fields were modified?
  3. Should this logic be implemented:
    • On client side using HandleViewModelAttributeChangeRequest?
    • Or in backend using the EntitySaving event and comparing old/new values?
  4. Is there a supported way to retrieve changed columns on the backend instead of manually comparing values?

I would like to follow the recommended and supported best-practice approach.

Thanks in advance!

Like 1

Like

1 comments

Client-side approach is to add a handler for the "crt.SaveRecordRequest" request. There you could validate and then return false to prevent the save from occurring. You'd likely also want to show a notification to the user for what is wrong. There is something in the $context that shows the changed, fields, but can't remember what it's called so you could throw it to the debugger to look.

For a server-side approach, you could implement an entity event listener. You could override the OnSaving (for both inserts and updates) to validate and then throw an exception if the validation fails. This will prevent the save and the UI will show the exception message in a toast notification to the user automatically. The EventArgs passed in will show you which fields have changed.

Ryan

Show all comments