Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

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.

Af: Tony Yates 4. mar 2020

RE: Execute script when follow-up is removed

Didn't think of that, thanks!

Af: Patrik Larsson 4. mar 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?

Af: Patrik Larsson 5. mar 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...

Af: David Hollegien 5. mar 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?

Af: Patrik Larsson 6. mar 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.

Af: David Hollegien 6. mar 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.

Af: Patrik Larsson 6. mar 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

Af: Conrad Weyns 6. mar 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.

Af: David Hollegien 6. mar 2020

RE: Execute script when follow-up is removed

Bringing up an old thread here.

Will we be seeing soon the possiblity to act with trigger when i.e appointment is deleted or getting more information in webhooks when a deletion is made?

Af: Patrik Larsson 23. feb 2021

RE: Execute script when follow-up is removed

Recently more details where added to the .deleted webhook events, see https://community.superoffice.com/documentation/sdk/SO.NetServer.Web.Services/html/Reference-Webhooks-ActivityEvents.htm

You could use a CrmScript that processes the webhook, as seen here

Af: David Hollegien 23. feb 2021

RE: Execute script when follow-up is removed

I see, thanks! But I still lack information I need, start and end date is not included.

Af: Patrik Larsson 23. feb 2021

RE: Execute script when follow-up is removed

Hi Patrik,

No, you will not "soon" see a BeforeDeleted trigger. Nor will you receive any info in a webhook other than the appointment ID that was deleted. 

We are aware these things are desired, and they are on wishes backlog.

Best regards.

 

Af: Tony Yates 23. feb 2021