Getting Appointment ID on AfterSave Trigger

Hi Forum :).

In a hope, that the answer is somewhere out there, I'll try my best to explain my problem..

I wan't to set some sentry-rights to an appointment through script. For this you have to know the appointment ID, because the section of the preference is of the form 'Rights-appointment-AppointmentId'.

The problem is the appointmentId isn't in the eventData object in the AfterSave trigger. Thus I can't create a relevant for this appointment.

I'm working on SuperOffice Online.

Any ideas/solutions out there?

RE: Getting Appointment ID on AfterSave Trigger

Hi, I agree that this is an issue. 

In the AfterSave event for Appoinment the ID is still 0 for newly created appointments:

Another issue here is that there is no eventdata for Completed, so it is not possible to see if the checkbox for completed has been set or not.

Av: Frode Lillerud 23. maj 2018

RE: Getting Appointment ID on AfterSave Trigger

I think this is a bug, but what you probably could do to get the Id is to fetch the last appointment. This might be a bad Idea anyway, because 2 appointment can be created at the same time.

To information, isNew is always false (the only check we can use is AppointmentId == 0) 

Av: Konrad Gislerud Andresen 23. maj 2018

RE: Getting Appointment ID on AfterSave Trigger

I'm glad I'm not the only one, who is annoyed by this :).

I know how to check if it's a newly created entity, but I'll just have to face, that what I want to do isn't possible.

@Konrad - I have thought about the same, where I could use MAX(appointmentId) + 10 or something, but this is a really ugly solution, and will properly screw things up at some point.

@someInsider - Is this expected behavior, or should we register this as a bug?

Av: Kasper Rosenlund 23. maj 2018

RE: Getting Appointment ID on AfterSave Trigger

Well, I found another solution :).

I used the associate ID, to look through the database for newest registered appointment. But only when appointment ID is 0 in the eventdata.

Av: Kasper Rosenlund 27. maj 2018

RE: Getting Appointment ID on AfterSave Trigger

Hi,

FYI: This bug, ID 59173, has been fixed and will be available in Online 8.3R03. For Onsite, next release is over the summer.

Sverre

Av: Sverre Hjelm 22. jun 2018

RE: Getting Appointment ID on AfterSave Trigger

Hi Frode,

Can I please ask what you are using to view the event data?

Many thanks,

Trevor

Av: Trevor Sharp 22. jun 2018

RE: Getting Appointment ID on AfterSave Trigger

Hello Trevor,

You can use the following code to log all the event data to the CS log:

EventData eventdata = getEventData();

log(eventdata.getInputValues().toJson());

And then put the output in a JSON formatter / prettifier.

Av: David Hollegien 22. jun 2018

RE: Getting Appointment ID on AfterSave Trigger

What David said.

Thats exactly what I did as well.

Av: Frode Lillerud 22. jun 2018

RE: Getting Appointment ID on AfterSave Trigger

Or create a trace for the script :)

Sverre

Av: Sverre Hjelm 25. jun 2018