Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin error after upgrading to 9.1 version from 8.2

(0) ShareShare
ReportReport
Posted on by 187

ErrorDetails-_2800_17_2900_.txtHi!

Upon putting some trace logs on our post Opportunity update plugin, I've known that the error is on getting the time zone of current logged in user. Please note that this is working on our 8.2 version.

Can anyone share their thoughts what happened on that one? Thanks!

Pasting the code snippet

tracingService.Trace("currentUserSettings start");
var currentUserSettings = service.RetrieveMultiple(
new QueryExpression(UserSettings.EntityLogicalName)
{
ColumnSet = new ColumnSet("localeid", "timezonecode"),
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("systemuserid", ConditionOperator.EqualUserId)
}
}
}).Entities[0].ToEntity<UserSettings>();


tracingService.Trace("currentUserSettings retrieve finish");

");

From the tracing above, "currentUserSettings retrieve finish" wasn't executed. Also pasting the entire error log details.

*This post is locked for comments

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    Hi,

    You can check the below initiating user id for the plugin execution-

    Entered MOLCrmPackage.Plugins.PostOpportunityUpdate.Execute(), Correlation Id: e007b78d-e065-43e1-9bf5-5f59ff245e84, Initiating User: 7b6801a0-a031-45f4-9072...)., Correlation Id: e007b78d-e065-43e1-9bf5-5f59ff245e84, Initiating User: 8c16893c-3407-e811-8148-e0071b69b721

    Exiting Microsoft.Dynamics.Sales.Plugins.PreOperationBpfInstanceUpdate.Execute(), Correlation Id: e007b78d-e065-43e1-9bf5-5f59ff245e84, Initiating User: 8c16893c-3407-e811-8148-e0071b69b721

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    Hi ,

    This is basic steps for any plugin , I believe you are aware that when we are calling execute method there is a inbuilt parameter of type  IServiceProvider  -

      public class FollowupPlugin: IPlugin

       {

           public void Execute(IServiceProvider serviceProvider)

           {

           }

    }

  • JZot Profile Picture
    JZot 187 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    Hi Goutam,

    Thanks for the reply.

    Sorry but where will the "serviceProvider" be coming from? Thanks!

  • JZot Profile Picture
    JZot 187 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    Hi Ravi

    THanks for the reply. Do you know how can I retrieve the GUID that is being passed in the query? As we can see in the screenshot its just using the "ConditionOperator.EqualUserId" code. Thanks!

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    Hi,

    As per my understanding, CRM is executing the OOB plugin "Microsoft.Dynamics.Sales.Plugins.PreOperationBpfInstanceUpdate" which is internal executing your custom plugin. In your code, you are retrieving the details of the current user id So I am suspecting that the users getting passed to your plugin is not correct.

    I would suggest to check the Guid value of the Initiating Users from the trace log and check if this is what you expect.

    Alternatively, to isolate the issue further, You can disable the OOB plugin and check if your plugin then works fine or not. This will confirm that if the issue is in your plugin or how its getting executed from the OOB plugin.

    Hope this helps.

  • Verified answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    Hi,

    You can retrieve the user GUID from context  -

    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); 

    IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);  // Calling User set in the plugin registration step
    IOrganizationService intiatingUserService = serviceFactory.CreateOrganizationService(context.InitiatingUserId); // User who trigger the action

     

  • JZot Profile Picture
    JZot 187 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    AH! You are correct. Upon checking the userID passed is "SYSTEM" which I think is really not a valid CRM user hence throwing the error.

    Do you know why is this happening only in 9.0 upgrade? Also, can you please suggest any workaround? Thanks!

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin error after upgrading to 9.1 version from 8.2

    If I am not wrong, this would be the from the context i.e. context.UserId which is typically the initiating user id if not changed/set. You can get this from your trace log file.

    community.dynamics.com/.../ms-crm-plugin-ipluginexecutioncontext-initiatinguserid-and-userid-plugintip2

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