Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

this issue is related plugin while creating and update appointment

(0) ShareShare
ReportReport
Posted on by 194

Plugin written for appointment for N number of Opportunities with same account and in Account Entity – Dealer is YES

A Plugin is written for Appointment entity to create appointment and Update appointment of Related Account to the Opportunities … If Customer(Account) has 10 or 20 opportunities………..

For exmaple

Account name- Tata Motors and it has 30 Opportunities and Dealer (field) is YES then it should create 30 appointment (Activity) with same all data field.

The Following Field will be Auto filled while creating and saved Appointment

7026.image3.JPG

And while doing or starting Appointment , iF user pick any one of appointment out of 30 appointment and mark complete then it should update all remaining (29) appointments and mark complete with data field information .

The Following Field will be Auto filled while Mark complete Appointment

User Click on any one appointment and click on start appointment button (Geo tagging is there, Store ACTUAL START TIME IN FIELD)     then

Write Notes in DCR Details field and then mar complete (Store ACTUAL END TIME) …

 

EXAMPLE-------------------------------------------

8182.image4.JPG

 

Now test part……

Testing with Account Dealer is YES

Tested from three Different users

User name- xxx

User name – xxxXXX

User name – admin(administrator)

Case 1- Success from all three users

image5.JPG

Marked completed and with Actual start and actual end and DCR details .

But if I open the records and then close it then following error is coming from end users not from Admin……

Error details …

image6.JPG

Error details…………..below..

<s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">Cannot update Closed or Cancelled Activity</faultstring><detail><OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance"><ActivityId>0479d869-ac3b-4db6-a014-f6c0357edf0a</ActivityId><ErrorCode>-2147220946</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"><KeyValuePairOfstringanyType><a:key>ApiExceptionSourceKey</a:key><a:value xmlns:b="www.w3.org/.../XMLSchema" i:type="b:string">Plugin/Microsoft.Crm.Common.ObjectModel.AppointmentService</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiOriginalExceptionKey</a:key><a:value xmlns:b="www.w3.org/.../XMLSchema" i:type="b:string">Microsoft.Crm.CrmException: Cannot update Closed or Cancelled Activity ---&gt; Microsoft.Crm.CrmException: Cannot update Closed or Cancelled Activity

   at Microsoft.Crm.ObjectModel.GenericActivityServiceBase.ThrowIfClosedOrCanceled(ActivityState stateCode, ExecutionContext context, Nullable`1 targetStateCode)

   at Microsoft.Crm.ObjectModel.GenericActivityServiceBase.ThrowIfInvalidForUpdate(BusinessEntity entity, ExecutionContext context)

   at Microsoft.Crm.ObjectModel.GenericActivityServiceBase.Update(IBusinessEntity entity, ExecutionContext context)

   at Microsoft.Crm.ObjectModel.CommunicationActivityServiceBase.Update(IBusinessEntity entity, ExecutionContext context)

   at Microsoft.Crm.Common.ObjectModel.AppointmentService.Update(IBusinessEntity entity, ExecutionContext context)

   at Microsoft.Crm.Common.ObjectModel.ScheduleService.RescheduleAction.LockedTransactedExecute()

   at Microsoft.Crm.Common.ObjectModel.ScheduleService.LockedTransactedValidationAction.TransactedExecute()

   at Microsoft.Crm.Common.ObjectModel.ScheduleService.TransactedValidationAction.Execute()

   at Microsoft.Crm.Common.ObjectModel.ScheduleService.Reschedule(CommunicationActivity activity, ExecutionContext context)

   at Microsoft.Crm.Common.ObjectModel.AppointmentService.&lt;&gt;c__DisplayClass17_0.&lt;Reschedule&gt;b__0()

   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)

   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)

   --- End of inner exception stack trace ---

   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)

   at Microsoft.Crm.Extensibility.PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context)

   at Microsoft.Crm.Extensibility.Pipeline.&lt;&gt;c__DisplayClass2_1.&lt;Execute&gt;b__0()</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiStepKey</a:key><a:value xmlns:b="schemas.microsoft.com/.../Serialization" i:type="b:guid">7dcbbb1b-ea3e-db11-86a7-000a3a5473e8</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiDepthKey</a:key><a:value xmlns:b="www.w3.org/.../XMLSchema" i:type="b:int">1</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiActivityIdKey</a:key><a:value xmlns:b="schemas.microsoft.com/.../Serialization" i:type="b:guid">0479d869-ac3b-4db6-a014-f6c0357edf0a</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiPluginSolutionNameKey</a:key><a:value xmlns:b="www.w3.org/.../XMLSchema" i:type="b:string">System</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiStepSolutionNameKey</a:key><a:value xmlns:b="www.w3.org/.../XMLSchema" i:type="b:string">System</a:value></KeyValuePairOfstringanyType></ErrorDetails><Message>Cannot update Closed or Cancelled Activity</Message><Timestamp>2019-02-01T11:28:58.432997Z</Timestamp><ExceptionRetriable>false</ExceptionRetriable><ExceptionSource i:nil="true"/><InnerFault><ActivityId>0479d869-ac3b-4db6-a014-f6c0357edf0a</ActivityId><ErrorCode>-2147220946</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/><Message>Cannot update Closed or Cancelled Activity</Message><Timestamp>2019-02-01T11:28:58.432997Z</Timestamp><ExceptionRetriable>false</ExceptionRetriable><ExceptionSource i:nil="true"/><InnerFault i:nil="true"/><OriginalException i:nil="true"/><TraceText i:nil="true"/></InnerFault><OriginalException i:nil="true"/><TraceText i:nil="true"/></OrganizationServiceFault></detail></s:Fault></s:Body></s:Envelope>

Testing with Account Dealer is No

User name- ABC

User name – CDE

User name – admin (administrator)

Case 2- Success from all users – as usual Appointment is completing but if I open the records and then close it then following error is coming from end users(User- ABC & User CDE) not from Admin User……………above error

image6.JPG

    

Next we have Journey Plan witch connect to Appointment Entity

Journey plan Entity Connected to Appointment Entity (Activities )

When A user create any Journey plan by Selecting From date AND End date and save this then ….

Example ….

7181.image1.JPG

Then bellow line get created ………………………….

4530.image2.JPG

 

And User entered following details like CITY, ACCOUNT, PRODUCT, OPPORTUNITES, ACTIVITY TYPE, REMARKS AND then save it……..

And once User save this it becomes appointment and it goes to Activity entity .

And Users as usual do appointment from activity.

Note- here in above line have three button like ,, SAVE CHANGES , ADD NEW APPOINTMENT AND DELETE. ..IF USER wants to add more appointment for same date , he can add as much as he can.

Problem Facing Issue is when plugin is enabled (on Create Step) then it is not letting to ADD NEW APPOINTMENT .

image8.JPG

If plugin is disabled (on Create Step) then User can ADD NEW APPOINTMENT.

And when User Open this appointment and follow same thing like start appointment and mark complete it then. User is not able to mark complete it ….following error is throwing..

image7.JPG

Error Details……………………………

<s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): nmCreateAppointment.CreateAppointment: System.NullReferenceException: Object reference not set to an instance of an object.</faultstring><detail><OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance"><ActivityId>75d0d0f4-519e-46d4-8c6e-740612ac5e57</ActivityId><ErrorCode>-2147220956</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/><Message>An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): nmCreateAppointment.CreateAppointment: System.NullReferenceException: Object reference not set to an instance of an object.</Message><Timestamp>2019-02-01T18:50:47.2382866Z</Timestamp><ExceptionRetriable>false</ExceptionRetriable><ExceptionSource>PluginExecution</ExceptionSource><InnerFault i:nil="true"/><OriginalException>System.NullReferenceException

   at nmCreateAppointment.CreateAppointment.Execute(IServiceProvider serviceProvider)

   at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.&lt;&gt;c__DisplayClass14_3.&lt;Execute&gt;b__0()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)

   at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)

   at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException><TraceText>

[AssociationPlugin: nmCreateAppointment.CreateAppointment]

[64d32358-b8f6-e811-a971-000d3af288b3: nmCreateAppointment.CreateAppointment: Update of appointment]

Entered Microsoft.Dynamics.Playbook.Plugins.PostOperationActivityCreateUpdate.Execute(), Correlation Id: e5102949-bcaf-4339-92db-3dd41774cf56, Initiating User: e3211309-9f1b-e811-a957-000d3af27f7f

Exiting Microsoft.Dynamics.Playbook.Plugins.PostOperationActivityCreateUpdate.Execute(), Correlation Id: e5102949-bcaf-4339-92db-3dd41774cf56, Initiating User: e3211309-9f1b-e811-a957-000d3af27f7f

Starting sync workflow 'South Region Send Mail on Appointment only For Chemist', Id: beea3f1e-ef25-e911-a978-000d3af27119

Entering ConditionStep1_step: This step checks if status completed and user designation type is chemist and Region South

Sync workflow 'South Region Send Mail on Appointment only For Chemist' completed successfully

Starting sync workflow 'North Region Send Mail on Appointment only For Chemist', Id: 8deb3f1e-ef25-e911-a978-000d3af27119

Entering ConditionStep1_step: This step checks if status completed and user designation type is chemist and Region North

Sync workflow 'North Region Send Mail on Appointment only For Chemist' completed successfully

Starting sync workflow 'West Region Send Mail on Appointment only For Chemist', Id: f6a03724-ef25-e911-a978-000d3af27119

Entering ConditionStep1_step: This step checks if status completed and user designation type is chemist and Region West

Sync workflow 'West Region Send Mail on Appointment only For Chemist' completed successfully

Starting sync workflow 'Appointment Completed Mail to Manager', Id: 9e8d2830-ef25-e911-a978-000d3af27119

Entering ConditionStep3_step: if status is Completed

Entering SendEmailStep5_step: Send mail to Manager

Entering ConditionBranchStep4_step:

Entering ChildWorkflowStep7_step: OEM develpmement

Entering StopWorkflowStep6_step: End WF

 

target appointment

Entered 1

 

</TraceText></OrganizationServiceFault></detail></s:Fault></s:Body></s:Envelope>

 

 written each and every steps to understand in better way.

I also have tried disable/enable the workflow but still no issuse is same ....
some where something is missing with some permission ...not sure what exactly.

if you want i can copy and paste the code also ..but please need solution , my work is stopped..

any help from any one ...they can contact me also 

with following details

91-9620847773

mail- amitamity81@gmail.com

thanks

 

*This post is locked for comments

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