We’ve developed some resources to help you work effectively from home during COVID-19 Click to learn more

Execute script when follow-up is removed

I need to execute a script when a follow-up is removed. Trigger can be used when a follow-up is saved, but I can't find that it can be used when a follow-up is removed. Is there a way to get this done?

RE: Execute script when follow-up is removed

As seen in the UI, triggers only support Before and After Save events. To achieve what you want, you can create a webhook for projectmember.deleted that invokes a script. Here is a forum post that contains example code that demonstrates how.

Von: Tony Yates 4. Mrz 2020

RE: Execute script when follow-up is removed

Didn't think of that, thanks!

Von: Patrik Larsson 4. Mrz 2020

RE: Execute script when follow-up is removed

Am looking into this and I need to get the contact_id (either direct or via appointment_id). But the documentation (https://community.superoffice.com/documentation/sdk/SO.NetServer.Web.Services/html/Reference-Webhooks-ActivityEvents.htm) states that the Changes[] for Activity.deleted does not contain any information.

Is that the case? Is there no way of knowing the id of the appointment or the contact for the deleted activity?

Von: Patrik Larsson 5. Mrz 2020

RE: Execute script when follow-up is removed

Hello Patrik,

The "PrimaryKey" value is the ID of the appointment that is deleted, retrieving the contact id of the appointment is going to be difficult since the record containing that data what just deleted...

Von: David Hollegien 5. Mrz 2020

RE: Execute script when follow-up is removed

So, got the ID from the PrimaryKey. But as the appointment has been deleted, no further information can be retrieved. I then assume we can not do anything with the company connected to the deleted company.

Am I making a correct assumption?

Von: Patrik Larsson 6. Mrz 2020

RE: Execute script when follow-up is removed

Yes that is an correct assumption, by default you will not be able to get info about the company from the deleted appointment using a webhook. There a possibility's for OnSite to add extra info to the webhook event but that is a complex endeavor.

A 'solution' here would be to keep track of appointment_id <-> contact_id in an extra table, and when you receive the delete webhook event you can look-up the contact id of the deleted appointment in the extra table.

Von: David Hollegien 6. Mrz 2020

RE: Execute script when follow-up is removed

Will then send in a wish to include such info. Had a similar case with the webhook for projectmember.deleted and the project ID not being included.

Von: Patrik Larsson 6. Mrz 2020

RE: Execute script when follow-up is removed

I know nothing about any of this but it seems to me that the Web/Online universe is missing what the Win client has in its COM events: the *BeforeSave and *BeforeDelete events.

/conrad

Von: Conrad Weyns 6. Mrz 2020

RE: Execute script when follow-up is removed

There are BeforeSave trigger events but there are indeed no BeforeDelete trigger events like in the Win client.

Von: David Hollegien 6. Mrz 2020