Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Custom Service User Context

(0) ShareShare
ReportReport
Posted on by

Hi there, 

When developing and calling a custom service in D365 F&O, is it possible to provide a user context so that audit fields like created by and modified by reflect another D365 F&O user rather than the user who is making the service call?  I have an external web application that runs as a service account.  The external web application calls other 3rd party APIs to get data that needs to be integrated into D365 F&O.  The external web application gets the data from 3rd party APIs and then calls a D365 custom service that I've created to synchronize the data from the 3rd party into D365.  This is functioning well but the audit fields on my D365 tables reflect the service account that is calling the custom service.  My users would like to see the records reflect as having been created by and modified by the user who created the record in the 3rd party system.  

Is there a pattern or any guidance that allows the D365 service method to run in the context of another user so that it can appear that another user called the service method instead of the service account that my web application is running as?  Any suggestions are greatly appreciated!  

  • Greg's Mom Profile Picture
    Greg's Mom on at
    RE: Custom Service User Context

    Thank you very much, I was unaware of this method.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    RE: Custom Service User Context

    Your custom service could utilize runAs() method.

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans