web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Owner of form and Field Security

(0) ShareShare
ReportReport
Posted on by 765

I'm looking for a solution similar to the 'Create' permission under 'Field Security', except, as is, when a user creates a new (let's say) Opportunity they can edit the field until they click save, then they can only read it (if that permission is set). I'm looking for a way so that owner of the field can edit it not only at creation, but thereafter too.  Is there a way to do this through settings? Can it be done through Javascript?

Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    AEdwards Profile Picture
    765 on at
    RE: Owner of form and Field Security

    --UPDATE--

    Field security is not so flexible as to allow this exactly, plus it's really not that convenient to use. What I ended up doing was making a Script that checks if the current user is the same user who created the field, or if they have a certain security role.

    var guidIDofRole = "00000000-0000-0000-0000-000000000000:;

    var roles = Xrm.Page.context.getUserRoles();

    var hasRole = false;

    //search through roles to see if any match guidIDofRole, if so set var hasRole to true;

    var createdBy = Xrm.Page.getAttribute('createdby').getValue()[0].id;

    var currentUser = Xrm.Page.context.getUserId();

    Xrm.Page.ui.controls.get('scheduledend').setDisabled(!((createdBy == currentUser) || hasRole));

  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at
    RE: Owner of form and Field Security

    AEwards,

    Might be I am miss understanding your problem.. I thought,.. Different users can create opportunities.. but when creating opportunity say user 1 added Name/Topic, potential customer and description for Opportunity 1, then user 2 cannot able to modify opportunity 1 Name/Topic, potential customer and description but user 2 can modify  probability, Discount etc for opportunity 1..

    If this is the case then you have to go with custom security module as I mentioned in above thread.

    If your problem is like.. user 1 create opportunity 1, and user 2 can only view opportunity 1 but not able to modify any field on it.. then you can use security role permission.. give only User level permission for create+write and higher than user level for read..

    Field level security is working like.. User 1 can add only Topics for all opportunities, and user 2 can view only Topics for all opportunities.. using field level security you cannot define like user 1 can do only these things for opportunity 1, and he cannot do same things for opportunity 2.

    Here are some links for CRM security..

    technet.microsoft.com/.../hh699698.aspx

    msdn.microsoft.com/.../gg309524.aspx

    www.powerobjects.com/.../hierarchical-security-model-dynamics-crm-2015-2

    blog.sonomapartners.com/.../dynamics-crm-2015-hierarchical-security.html

    technet.microsoft.com/.../dn832104.aspx

    msdn.microsoft.com/.../gg309608.aspx

    Hope this will help..

    Thanks,

  • AEdwards Profile Picture
    765 on at
    RE: Owner of form and Field Security

    In Javascript, couldn't I just check the 'Created By' field to see who created the record and compare it with the current user's ID; The question was more:

    Is there a way to do what I want without creating a script, or if I do have to create a script, can javascript alter the field even with Field Security on?

  • Mahadeo Matre Profile Picture
    17,021 on at
    RE: Owner of form and Field Security

    Hi AEwards,

    I think you can do this using JavaScript, and when auditing is enabled for that entity.

    You need to write JavaScript on Form load and form mode is update.

    Using JavaScript you can retrieve audit history for that record, and in that audit history check for who created which fields.. based on that you can make read only attributes.

    Here is some example

    mileyja.blogspot.com/.../retrieve-attribute-history-and-audit.html

    Retrieving data from audit history might be create performance issue on this form.. depend on how many entities and attributes you enabled for auditing..

    Another option would be--

    Create one custom entity with 1:N relationship with your entity.. and in this entity you can create two attributes - User (look up for system user) and one text box to store attributes list entered at the time of creation.

    Then you need to create plugin which will fire on Create and update of your entity.

    and in Plugin.. you need to create list of attributes based on data entered.

    Then add JavaScript on form same way as audit, and retrieve data from this custom entity for this record and by user.. you will get list of attributes which are added at the time of creation.. and then based on that you can make read only attributes on form.

    Hope this will help to solve problem. 

    Thanks

  • AEdwards Profile Picture
    765 on at
    RE: Owner of form and Field Security

    That wouldn't work (as far as I can tell) because then you can't have a dynamic value (like Owner) in the field requirement.  Let's say I have 2 users: UserA and UserB, if UserA creates a new opportunity I want him, and only him, to be able to edit Field1, while UserB can only view Field1.  Whereas, if UserB creates their own Opportunity they can edit Field1, but UserA can only view it. Does that help?

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: Owner of form and Field Security

    AEdward,

    If I am not mistaken translating your rquirement here:

    "I'm looking for a way so that owner of the field can edit it not only at creation, but thereafter too."

    What if you just give them permission to Write + Create in the field level security, so that the user can do both create or edit the field.

    Or maybe something I miss from that?

    Kindly elaborate more.

    Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans