Announcement

Collapse
No announcement yet.

Rendering fields read only based on assigned user

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rendering fields read only based on assigned user

    Hi all

    I have managed to remove field divs post render based on which user is logged in - Admin, assigned user or other user with no issue using the following:
    this.$el.find('div[data-name="emailAddress"]').addClass('hidden');

    Asking if there is a way to set a field (or fields) as read only - in other words, include the field as visible (do not hide using above code) but make it read only unless you are an admin or the assigned user. This would result in the record being able to be read, but only certain fields would be editable unless you are the record owner.

    As an example we can use an opportunity record.
    If you are Admin level or the assigned user - full access
    If you are another user, you can see the record (some divs may be hidden as above), and if they choose edit they can change the close date and add another contact, but they can't change the account or amount or stage as these are dynamically set to read only.

    So only some fields are "locked" - read only, and others can be edited. To my knowledge roles can not achieve this as it is all or nothing - you can't assign different permissions based on assigned user (hint hint for a new feature).

    I am using Version 5.7.11 because my server requires MySQL5.6 for other projects.

    Any suggestions? All input welcome.

    Sorry should have mentioned this is in connection with https://docs.espocrm.com/development/custom-views/
    Last edited by nickh; 01-16-2021, 09:33 AM.

  • #2
    Couldn't you just use Dynamic logics (right at the end) sample URL to this setting: /#Admin/fieldManager/scope=Opportunity&field=description

    For this?
    There three option here:
    Code:
    Conditions making field visible[URL="http://javascript<b></b>:"]Edit[/URL]
    None
    
    Conditions making field required[URL="http://javascript<b></b>:"]Edit[/URL]
    None
    
    Conditions making field read-only[URL="http://javascript<b></b>:"]Edit[/URL]
    None
    Might need to play with it to get it working like you require though. There may also be some limitation.

    Comment


    • punkyard
      punkyard commented
      Editing a comment
      Hi, could you adapt your example with nickh's case?
Working...
X