Issue with Refreshing Detail View

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomasrotek
    Junior Member
    • Sep 2024
    • 3

    Issue with Refreshing Detail View

    Hello,

    We are currently encountering a challenge in our project where we need to refresh the complete detail view for the Contact entity.

    In our project, we have implemented custom ACL (Access Control Logic). All users have access to view all contacts, but some users, based on certain criteria, can only view (not edit) certain fields. These restricted fields are filtered out using OutputFilter on the backend and hidden in the frontend within the record/detail.js file using the hideField function.

    When a user is unable to edit the entity due to restrictions, an "Unlock" button appears. Clicking this button adds the user to the unlockedByUsers field, which grants them access to view and edit all fields of that entity.

    The issue arises after pressing the "Unlock" button — we need to refresh the entire view. On the backend, after the unlock action occurs, we attempt to refresh on the frontend with the following code:

    PHP Code:
    this.model.fetch();
    this.reRender(); 
    
    However, this approach does not fully refresh the view; the hidden fields remain hidden (even though they are correctly fetched in the model), and the edit mode is not enabled as expected.

    We attempted to manually manage this logic using showField, but this approach is not working.

    Currently, our workaround is to use location.reload();, but we are eager to implement a more appropriate solution.

    Could someone please assist us with potential solutions?
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1606

    #2
    Couldn`t you achieve this by conditional logic on field level in the admin GUI?

    Comment

    • yuri
      Member
      • Mar 2014
      • 8453

      #3
      Did you add an event handler to this.model to listen to changes and hide/show field depending on conditions. If not, consider this approach. No need to call reRender then.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1250

        #4
        Originally posted by tomasrotek
        Hello,

        We are currently encountering a challenge in our project where we need to refresh the complete detail view for the Contact entity.

        In our project, we have implemented custom ACL (Access Control Logic). All users have access to view all contacts, but some users, based on certain criteria, can only view (not edit) certain fields. These restricted fields are filtered out using OutputFilter on the backend and hidden in the frontend within the record/detail.js file using the hideField function.

        When a user is unable to edit the entity due to restrictions, an "Unlock" button appears. Clicking this button adds the user to the unlockedByUsers field, which grants them access to view and edit all fields of that entity.

        The issue arises after pressing the "Unlock" button — we need to refresh the entire view. On the backend, after the unlock action occurs, we attempt to refresh on the frontend with the following code:

        PHP Code:
        this.model.fetch();
        this.reRender(); 
        
        However, this approach does not fully refresh the view; the hidden fields remain hidden (even though they are correctly fetched in the model), and the edit mode is not enabled as expected.

        We attempted to manually manage this logic using showField, but this approach is not working.

        Currently, our workaround is to use location.reload();, but we are eager to implement a more appropriate solution.

        Could someone please assist us with potential solutions?
        if you manage how to hide/show fields in a method you can listen to an event listener using listen to change and call the method it will make fields visible and hide others based on conditions. This is what i always tend to use instead of calling this.Rerender()
        Rabii
        Web Dev

        Comment

        Working...