Hello everyone,
I am posting this question with a desperate need of help,
And to give you some context, we have a custom Action that sends email notifications and I have a plugin that calls that custom action and sends email notification.
It works when called from an administrator user and at top of Organization, but when I try to execute it from a different user from a child BU with different priviledges, I get the error. "Object reference not set to an instance of an object".
That 2nd user has still access to the parameters needed to send the notification, notification config ref, ent. logical and ID ( Regarding Case )
Any ideias what might be causing this, please?
Logs from plugin:
Custom Action:
Plugin Calling the action:
try { OrganizationRequest req = new OrganizationRequest("noesis_NotifyOnDemand"); req["Target"] = notificationConfigRef; req["NotificationConfiguration"] = notificationConfigRef; req["EntityLogicalName"] = targetEntityReference.LogicalName; req["EntityId"] = targetEntityReference.Id.ToString(); req["CreateAsDraft"] = createAsDraft; req["SplitToRecipients"] = splitToRecipients; TracingService.Trace($"Requesting Notification...\nParameters: {JsonConvert.SerializeObject(req.Parameters)}"); OrganizationResponse response = Dynamics365Context.Execute(req); return response; } catch (Exception ex) { TracingService.Trace($"***Exception*** - Requesting Notification... Message: {ex.Message}, InnerException: {ex.InnerException}"); throw new InvalidPluginExecutionException($"Exc. Message: {ex.Message}"); }
Successfull Call
Target: incident | 818f1d1e-b10b-ed11-b822-00155d20085f Service Provider not null Plugin Execution Context not null Organization Service Factory not null Organization Service not null IncidentManager is null? : False PreImage is null? : False START -- CheckAndExecuteCaseTypeOptions Case Type Config: ebf093f8-15e8-ec11-b853-00155da304b1 Returned Case Type Options count: 7 SKIP -- Case Status != CTO Status: WaitingforInfo != Open? True SKIP -- Case Status != CTO Status: WaitingforInfo != WorkInProgress? True Found a CTO with matching status reason : WaitingforInfo and with Notification Configuration [Case Flow] - Notificações SmartPOS d601ba5e-12e8-ec11-b853-00155da304b1 Requesting Notification... Parameters: [{"Key":"Target","Value":{"Id":"d601ba5e-12e8-ec11-b853-00155da304b1","LogicalName":"noesis_notificationconfiguration","Name":"[Case Flow] - Notificações SmartPOS","KeyAttributes":[],"RowVersion":null}},{"Key":"NotificationConfiguration","Value":{"Id":"d601ba5e-12e8-ec11-b853-00155da304b1","LogicalName":"noesis_notificationconfiguration","Name":"[Case Flow] - Notificações SmartPOS","KeyAttributes":[],"RowVersion":null}},{"Key":"EntityLogicalName","Value":"incident"},{"Key":"EntityId","Value":"818f1d1e-b10b-ed11-b822-00155d20085f"},{"Key":"CreateAsDraft","Value":false},{"Key":"SplitToRecipients","Value":false}] Notification was sent successfully. ActivityIds a9bbc067-0b0c-ed11-b822-00155d20085f END -- CheckAndExecuteCaseTypeOptions -- END
ERROR LOG
Target: incident | 818f1d1e-b10b-ed11-b822-00155d20085f Service Provider not null Plugin Execution Context not null Organization Service Factory not null Organization Service not null IncidentManager is null? : False PreImage is null? : False START -- CheckAndExecuteCaseTypeOptions Case Type Config: ebf093f8-15e8-ec11-b853-00155da304b1 Returned Case Type Options count: 7 SKIP -- Case Status != CTO Status: Pendingthirdparties != Open? True SKIP -- Case Status != CTO Status: Pendingthirdparties != WorkInProgress? True SKIP -- Case Status != CTO Status: Pendingthirdparties != WaitingforInfo? True Found a CTO with matching status reason : Pendingthirdparties and with Notification Configuration [Case Flow] - Notificações SmartPOS d601ba5e-12e8-ec11-b853-00155da304b1 Requesting Notification... Parameters: [{"Key":"Target","Value":{"Id":"d601ba5e-12e8-ec11-b853-00155da304b1","LogicalName":"noesis_notificationconfiguration","Name":"[Case Flow] - Notificações SmartPOS","KeyAttributes":[],"RowVersion":null}},{"Key":"NotificationConfiguration","Value":{"Id":"d601ba5e-12e8-ec11-b853-00155da304b1","LogicalName":"noesis_notificationconfiguration","Name":"[Case Flow] - Notificações SmartPOS","KeyAttributes":[],"RowVersion":null}},{"Key":"EntityLogicalName","Value":"incident"},{"Key":"EntityId","Value":"818f1d1e-b10b-ed11-b822-00155d20085f"},{"Key":"CreateAsDraft","Value":false},{"Key":"SplitToRecipients","Value":false}] ***Exception*** - Requesting Notification... Message: Object reference not set to an instance of an object., InnerException:
Thank you,
Best regards