Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plug-in context: business unit id problem

(0) ShareShare
ReportReport
Posted on by 2,100

We upgraded a CRM 2016 organization to Dynamics 365/CRM. A plug-in that ran fine in 2016 is no longer working correctly in D365.

The plug-in checks the BusinessUnitId from the plug-in context and changes logic based on the GUID.

The problem is that BusinessUnitId is set to the base organization business unit, not to the calling user's actual business unit.

Example: I have a user who is in Business Unit "West". The top-level business unit id is "Corp". The plug-in is registered to run pre-operation synchronous for the "Calling User".  I logged in as the user and performed the action to trigger the plug-in. In the plug-in, I trace-out the user's business unit from the context. The plug-in trace says that the user's business unit is for "Corp", not for "West". I double-checked that the user is assigned to the "West" business unit.

Has anyone else run into this change to how D365/CRM is setting the calling user's BusinessUnitId value?

*This post is locked for comments

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,081 Moderator on at
    RE: Plug-in context: business unit id problem

    Hi Tim,

    I double check. It will always giving or setting root business unit.

    You are right. We should have to use UserId to get it's business unit.

    Thanks

    Regards,

    AW

  • Tim Dutcher Profile Picture
    Tim Dutcher 2,100 on at
    RE: Plug-in context: business unit id problem

    The work-around I had to put in place is to query for the user's business unit if the plugin BusinessUnitId is the base business unit GUID. It's a bit of a performance hit but resolves the issue for now.

  • Tim Dutcher Profile Picture
    Tim Dutcher 2,100 on at
    RE: Plug-in context: business unit id problem

    What's really strange is that the BusinessUnitId is switching between the correct one and the top-level business unit seemingly randomly.  

    I just created three records, logged-in as the same user, about one minute apart. The plug-in trace log shows the correct business unit once but the two other log records show the top-level business unit.

    So, without doing anything in CRM besides creating three records, the plug-in context is setting BusinessUnitId to two different values!

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans