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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Plugin's InitiatingUserId dilemma

(0) ShareShare
ReportReport
Posted on by 50

Hi everyone,

i'm trying to solve an issue i'm experiencing on a couple of plugins in my client's environment, here's the scenario:

  1. User A creates a record "Interest"

  2. "Interest" creation triggers a plugin running on "SYSTEM (Disabled)" context. InitiatingUserId is User A in this case (everything's fine until now).
    The plugin creates a record "Brand Data".

  3. "Brand Data" creation triggers another plugin, always in "SYSTEM (Disabled)" context. Depth is 2 and InitiatingUserId is SYSTEM in this case.

In point 3 i was expecting that the InitiatingUserId, which the documentation describes as the "user who started the pipeline", would be actually propagated to each plugins' chain level. Also observing plugin ParentContext the value isn't the expected one

  • Actual plugin context: EntityName = "Brand Data", InitiatingUserId = "SYSTEM"
  • Parent plugin context: EntityName = "Interest", InitiatingUserId = "SYSTEM" -> this is against point 2

I thought i understood how InitiatingUserId works, but it's clear i'm missing something.

Can please someone explain the current behaviour of this property and user impersonation in a plugin chain like this?

Thanks in advance,

DT

PS. The environment is a Dynamics 365 v9.1 online.

I have the same question (0)
  • Verified answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hello,

    3rd point where initiating user id is System beacuse you are creating record using Organizationservice which is created using system.

    When you create organizationservice using context.initiatinguserid then you will same user in 3rd point.

    please check your orgnaizationservice object as how you have created in your plugin. Are you passing null value or guid.empty as parameter.

    IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

    IOrganizationService service = serviceFactory.CreateOrganizationService(null); -- It will take system

    IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId); -- It will take same initiating user as point 1

    Please mark my answer verified if i were helpful

  • Daniele.Torlai Profile Picture
    50 on at

    Hi,

    so all i have to do is to set "InitiatingUserId" in serviceFactory.CreateOrganizationService before i create the Brand Data record in the 1st plugin (POINT 2) in order to propagate the user also in the 2nd plugin (POINT 3).

    Did I get it right?

  • Suggested answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hey,

    That is correct.

    Please mark my answer verified if i were helpful

  • Daniele.Torlai Profile Picture
    50 on at

    It worked like a charm,

    Thank you so much for pointing me to the right solution.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 196 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans