Null Exception after calling RadScheduleViewCommands.EditAppointment.Execute

2 Answers 30 Views
ScheduleView
Richard
Top achievements
Rank 1
Iron
Richard asked on 02 Dec 2021, 05:50 PM

Hello.

this is version 2020.1

I have a scheduler working nicely (lots of customizations...)

Now, I am trying to edit an appointment calling RadScheduleViewCommands.EditAppointment.Execute:


public void EditAppointmentWithDialog(AppointmentDTO appointmentData)
        {
            var appo = PersistenceLayer.FindAppointment(appointmentData.ID);
            ScheduleView.scheduleView.CurrentDate = appo.AppointmentDate;
            var newAppo = Appointments.FirstOrDefault(app => app.ID == appointmentData.ID);
            ScheduleView.scheduleView.SelectedAppointment = newAppo;
            RadScheduleViewCommands.EditAppointment.Execute(null, ScheduleView.scheduleView);
        }

void IEditableObject.BeginEdit  is called, so everything is in place.

If I cancel the edit, everything goes fine.

If I just click Ok in the edit window, void IEditableObject.EndEdit is never called.

I get a null exception error and the program exits.

See the attached file for the exception log.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Richard
Top achievements
Rank 1
Iron
answered on 08 Dec 2021, 12:43 PM

Hello.

Well, the error is gone.

I fixed a call to an external service. My guess is something else was silently firing an exception resulting in the nullification of the occurrence.

So far so good, the edition of the appointment is working as expected.

Also, I implemented the ReadOnlyBehavior to catch the null error and present some info if anything like that happen again.

Thank you for your help!


Dilyan Traykov
Telerik team
commented on 08 Dec 2021, 03:08 PM

Hello Richard,

I'm glad to hear that you've managed to resolve the error and want to thank you for sharing this information.

Should you come across any further issues I'd be more than happy to help again.
0
Dilyan Traykov
Telerik team
answered on 06 Dec 2021, 01:43 PM

Hello Richard,

Thank you for the provided code snippet and stack trace.

It appears that for some reason the following occurrence in the CanEditAppointment method of the control is null:

		public virtual bool CanEditAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
		{
			Slot slotToCompare = new Slot(occurrence);
			slotToCompare.Resources.AddRange(occurrence.GetResources());
			return this.CanEditSlot(readOnlySettings, slotToCompare);
		}

I was, however, unable to reproduce this exception with the examples from our SDK Samples Browser which leads me to believe it may be caused by some custom logic.

Can you please specify whether you've defined any custom dialogs or modified the default dialogs in any way?

Ideally, can you please isolate this exception in a small sample project or use the one I've attached to my reply for the purpose? Thank you in advance for your cooperation on the matter.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Richard
Top achievements
Rank 1
Iron
commented on 06 Dec 2021, 04:19 PM

Thank you for the answer!

 

That seems to mean that the appointment being sent is NOT an IOccurrence? Or that the occurrence is incomplete?

I did modify the default dialog. Added some properties from our own Appointment type for edit (mainly states: arrived, no show, etc, and some brushes management based on those, as well as provider, patient -it's a clinic scheduler...).

I could test the following, tho:  If I edit the very same appointment via a click in the scheduler sheet (which calls the same modified custom dialog), it works.

Also, I have a separate dialog to find appointments with several criteria, and if I click on those (which results in a call to the same

RadScheduleViewCommands.EditAppointment.Execute

call (showing the same edit dialog) it also works.

There is some sync which does not fill in the slot it seems?

Maybe I should overwrite the call to

CanEditAppointment

and see what happens there...

 

I'll keep you posted.

 

Dilyan Traykov
Telerik team
commented on 07 Dec 2021, 03:20 PM

Hello Richard,

Indeed, it is also possible that the passed object is not an IOccurance and this is the reason for the exception to be thrown.

Upon further investigation, if null is passed as the parameter of the EditAppointment command, the SelectedAppointment object will be used for the edit operation. Can you please check whether this property is indeed set prior to executing the command? To clarify - I notice that you've manually set it, but my question is whether for any reason afterwards the property gets set back to null.

You can also try to pass the acquired newAppo object to the EditAppointment command and see if this resolves the issue:

RadScheduleViewCommands.EditAppointment.Execute(newAppo, ScheduleView.scheduleView);

Please let me know how this goes.

Richard
Top achievements
Rank 1
Iron
commented on 07 Dec 2021, 06:32 PM

Hello.

As you can see from the code above, the SelectedAppointment is set in the previous line.

I did debug it and it is set, and the object indeed IS an IOccurrence.

In fact, I stripped out a verification where if newAppo is null I build a new Appointment object from the persisted one, add it to the list of Appointments, set it to SelectedAppointment and then call the Execute function.

As I mentioned before, even the BeginEdit function is called and I can stop the call in debug mode.

I tried both passing null  and passing the selectedAppointment to the Execute funcion with the same result.

 

Tags
ScheduleView
Asked by
Richard
Top achievements
Rank 1
Iron
Answers by
Richard
Top achievements
Rank 1
Iron
Dilyan Traykov
Telerik team
Share this question
or