How can I allow a user to only edit the fields they have filled in. ( Field-Level Access Control )

0
Hi Yall.   I have the following requirements and was curious if anyone has ever done something like this before:   A field becomes editable when a user inputs a value for the first time. Fields with existing values pre-filled from another source (another user or system) are read-only. Once the user fills in a field, it remains editable only for them, until submission or save. After submission, fields should be locked unless reopened through a specific action that respects user roles and permissions. Visual indicators (such as grayed-out fields or lock icons) should show whether a field is editable or read-only.   Setting an association for each attribute to track seems like a lot of building on top of a simple form   1. are there easier ways to do this 2.  how would you scope this, as in: how much time should it take to do 1 attribute?
asked
3 answers
2

Hello Jason,

Make a non persistent entity with all the fields. Create for each field a editable boolean. Use conditional visibility to show either the non editable field or the editable field. On the save button process the non persistent entity and transfer all the fields to their corresponding attributes in other entities.

Regards,

Ronald

 

answered
1

Hi Jason , 

 

1. On a new edit page, place an input widget like a textbox. By default, when users open the page, the field should be editable.

2.In the domain model, configure access rules for the entity.

  • For the user role, grant full read and write access, and enable the ability to create and delete objects.
  • For other roles, set access rules to grant read-only access, ensuring they can view but not edit or write data created by others.
  • This ensures that a user can edit only their own data while having read-only access to others' data.

3.

  • For the input field, create a visibility-based logic using a Boolean attribute (e.g., $yourentity/IsVisible):
    • Initially, set $yourentity/IsVisible=false  so that the field is editable.
    • Once the user enters a value and completes the process (e.g., submits or saves), update the $yourentity/IsVisible attribute totrue before committing the changes to the database.
    • On reopening the record, the input field will now appear as non-editable.

4.  On the Save or Submit button, ensure that before committing the changes, you:

  • Set $yourentity/IsVisible=True
  • This locks the fields for further edits unless reopened through specific actions (e.g., an admin unlocking them based on roles and permissions).

5. Mendix has a default greyout functionalities for non-editable fields , if you have to show the lock icon or anything try using CSS-Class to show lock icon or non-editable field .

 

Good Luck !!!

 

Thanks .

answered
0

Based on your requirements, I think we can achieve this using conditional editability of a field in Mendix.

Key Features:

  • Initial Editability: A field becomes editable when a user inputs a value for the first time.
  • Pre-filled Values: Fields with existing values pre-filled from another source are read-only.
  • User-specific Editability: Once the user fills in a field, it remains editable only for them, until submission or save.
  • Locked Fields after Submission: After submission, fields should be locked unless reopened through a specific action that respects user roles and permissions.
  • Visual Indicators: Visual indicators (such as grayed-out fields or lock icons) show whether a field is editable or read-only.

To implement this, you could create a custom validation rule that checks if the field's value is empty or not. If it's empty, the field would be editable; otherwise, it would be read-only. This approach might require some additional logic to handle the "reopened" scenario, which could involve creating a new entity or using a staging entity as mentioned earlier.

answered