web
You’re offline. This is a read only version of the page.
close
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 193

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

I have the same question (0)
  • RaviKashyap Profile Picture
    55,410 Moderator on at

    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

  • JZot Profile Picture
    193 on at

    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!

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    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

     

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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.

  • JZot Profile Picture
    193 on at

    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!

  • JZot Profile Picture
    193 on at

    Hi Goutam,

    Thanks for the reply.

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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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)

           {

           }

    }

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans