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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to achieve the functionality on user entity.

(0) ShareShare
ReportReport
Posted on by 6

Hello All Experts,

I have two custom fields on the user entity form.

i want this fields needs to be filled or updated by the user who is only logged in.

i mean the user himself needs to create or update the record but not the other user should do anything with this.

why i am asking this question because user form is visible by anybody who logged in to the crm.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    What data you can modify and can create depends on your security role, if other user have permission they will be able to update user record. One option could be to implement your custom plugin logic to restrict update on your field, you can validate if user record GUID match with current user GUID only then allow them to save otherwise throw error.

    Thanks

  • EmployeeOcta Profile Picture
    6 on at

    Hello Himbap,

    if i follow below logic inside the custom plugin will that work.

    if (userid belongs to System Administrator Role OR System Customizer role OR dbuserid=userid)

    // logic here for create or update

    else

    message as permission issue.

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Yes, you don't want to put logic if your condition is true so you can simply check

    If(user !=Sys Admin or Sys Customizer or dubuserid=currentuserid)

    throw exception

    Thanks

  • EmployeeOcta Profile Picture
    6 on at

    Hello Experts,

    I am confused on one point , how do i know the logged in user is same and he himself is updating the form.

  • EmployeeOcta Profile Picture
    6 on at

    Hello HIMBAP,

    the dubuserid=currentuserid  is i think wrong?

    i think we need to check entityid=currentuserid  

  • ashlega Profile Picture
    34,477 on at

    It's probably the same - dbuserid would likely mean entityid in the context of this thread

    BTW, another way to do this would be to create a new custom entity, and to put those fields there.. then to have a lookup from the user entity to that new custom entity.. And to assign that lookup record to the user (then you will be able to control access through the security roles)

  • EmployeeOcta Profile Picture
    6 on at

    Hello Alex,

    I am thinking of when user A logs in CRM and open User B form and try to update two fields of User B form at that time how will i know that the form is being by the same person whose form it is.

    I mean User B should only modify his fields and not User A.

    this thing i want to achieve using Plugins.

  • ashlega Profile Picture
    34,477 on at

    Hi,

     I think that's exactly what you discussed with HIMBAP - just check if context.userId is the same as the ((Entity)context.InputParameters["Target"]).Id

     If, on the other hand, you wanted to avoid using a plugin.. you could move those fields to a dedicated user-owned custom entity, add a lookup to the System User entity (which would be referencing that custom entity), and configure security to only allow access to the records owned by the user. In that case, your users won't be able to fill in such fields directly on the system user form, but they could open that custom entity through the lookup field and update the fields. You'll have to make sure they can't update the lookup itself, so you may also need field security.. and you may also need a workflow running under your own admin account to initially populate that lookup whenever a system user record is created.

  • EmployeeOcta Profile Picture
    6 on at

    Hello Alex,

    I cannot do like that because the system already moved on production.

    whatever is there i need to do it on this existing form only.

  • ashlega Profile Picture
    34,477 on at

    Then you have to use a plugin as HIMBAP suggested (although, technically it's also a change in production.. but it's "hidden" from the users)

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans