Organizer activity party name coming as null

Here comes the interesting issue. I want to know any settings makes this difference or any workaround to get it right.

We have different Dynamics 365 CRM online instances but all are identical as they are refreshed from Prod. Recently developed plugin code behaves differently across the environments.

var organizers = (EntityCollection)appointment["organizer"];
Entity record = organizers.Entities[0];
EntityReference organizer = (EntityReference)record["partyid"];

On appointment creation, the post-create async plugin code read the organizer - one of the activity party field but the result is very different. Though systemuserid is identical, the name is coming from that entity reference properly in Dev but coming as null in other environments.

enter image description here

enter image description here

Upvotes: 2

Views: 489

Answers (2)

MS agreed this as a bug, but actually this context difference is identified between the classic web UI & the UCI. Only for appointment entity, because of some oData response known issue - UCI target entity is missing the formatted values.

I got the plugin profiler log from my QA team so I didn't realize they were testing in UCI but I tested in web, so the quick watch showed the difference while replay/debugging.

Anyway until MS prioritize & fix this bug, I have the below workaround to unblock this issue.

#region Workaround for fixing UCI app EntityReference coming as empty string

            if (string.IsNullOrEmpty(organizer.Name))
            {
                ctLog.Log("organizer.Name is empty");
                fetch = string.Format(@"<fetch>
                                          <entity name='systemuser' >
                                            <attribute name='fullname' />
                                            <filter type='and' >
                                              <condition attribute='systemuserid' operator='eq' value='{0}' />
                                            </filter>
                                          </entity>
                                        </fetch>", organizer.Id);

                ctLog.Log("fetch built");
                results = userOrgService.RetrieveMultiple(new FetchExpression(fetch));
                ctLog.Log("results count: " + results.Entities.Count);

                if (results.Entities.Count > 0)
                {
                    organizer.Name = results.Entities[0].GetAttributeValue<string>("fullname");
                }
            }

#endregion

Upvotes: 0

Aron
Aron

Reputation: 3945

That is a strange problem indeed. If you hadn't refreshed the other orgs from PROD, I would say maybe there's a different image registered in the plugin registration.

Since the code, environment, plugin registrations, and even record ID are the same, this one might be worth a Microsoft support ticket.

In the meantime, a workaround would be to check if Name is null, and if so, retrieve the Name. It's another call to the system, but will allow you to proceed while you see if Microsoft can offer any insight.

Upvotes: 1

Related Questions