Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Created/Modified Delegated By in Plugin

Posted on by 15

Hello,

We have an entity that we don't want users to manually create or edit records on. The records are created and updated via plugin. I was under the impression that if the plugin is set to "Run In Users Context" set to "System" for example, I can create/edit these records via the plugin - the records will then have the created/modified by value set to the system user, but the delegate fields set to the users initiating the plugin. 

This doesn't seem to be the case however. Whilst the records are created and updated OK, the delegate fields are only ever blank. I've tried creating the OrganisationService with the various caller, initiating user IDs and so on. In terms of results, it's as you would expect - if the service is created using the system account, the records are created and updated OK but setting it to the initiating user throws an error that the user doesn't have privileges to perform the action. However in no scenario do these fields get populated. 

Have I misunderstood the delegate/on behalf fields? I've read that the above is what they should do, but maybe that was misinformation!

Cheers

P.s. the link below shows what I was expecting, but it's just not doing this - and if it's of any use, we are using XrmToolKit, though I don't think that would make any difference. But here is the organisation service code it uses:

this.OrganizationService = this.ServiceFactory.CreateOrganizationService(this.PluginExecutionContext.UserId);

community.dynamics.com/.../modified-by-delegate-created-by-delegate-in-d365

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Created/Modified Delegated By in Plugin

    Hi kubab,

    You should need to raise a ticket to support from Power Platform Admin Centre.

  • kubab Profile Picture
    kubab 15 on at
    RE: Created/Modified Delegated By in Plugin

    Hi Abdul, thanks for that - 1st link is the link I'd already posted.. this is the functionality I am expecting you see, but it's not what I'm getting.

    My plugin executes as System, and when debugging I can see that the user is indeed System and the initiating user ID is the actual user that triggered the plugin, so these things are as expected. But creating/updating doesn't ever seem to populate the delegate fields as that article suggests it should, hence my confusion. I only ever see System in the created by/modified by fields. I am expecting that, but I am also expecting to see the initiating user to be populated in the delegated fields. I can't set these fields in the plugin.

    Cheers

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans