Catch signal of an inserted record in database

Hello Community,

There is a bug in the system regarding the 'Contact in Folder' object, because apparently uses InsertQuery directly into the database, instead of the InsertQuery class.This object doesn't throw signals. How can we capture the event of an added record in such a scenario ?

Thank you

Sasori

Like 0

Like

10 comments

Hello,

 

Could you please provide us with an example of the InsertQuery which is not working?

Hello,

Object name is ContactInFolder. If you try to catch an event ( when contact is added to a Static Folder) through a Business Process, the business Process wont trigger.

My question is how to catch the event of adding Contacts to a Static Folder?

Sasori Oshigaki,

 

Hello,

 

And is the option with the business process with the timer that starts each 1 hour and reads records that were created in the previous 1 hour suitable here? You can read data and process it in this way. 

Hello Oleg,

Thats the solution we are providing for the moment. Thought that it was better to do something more performant, that doesnt overload the system by executing each hour.

Thank you

Hello,

Besides the option that Oleg provided, another variant is to create a trigger in the DB because normal events like OnInserted won't work with INSERT INTO.

Hello Dmytro,

Thank you for your answer. Is there anywhere in the system a similiar implementation of a trigger, so that we can take it as a reference while we develop our own ?

Thank you,

Sasori

The system rarely uses database triggers so it would be hard to provide a suitable example.

It would be better to search trigger examples in the DB documentation

Thank you for your reply Dmytro!

 

Hello Dmytro,

I created this trigger

CREATE OR ALTER Trigger [dbo].[trigger_InsertContactInFolderAfterEvent] 
ON [dbo].[ContactInFolder]
AFTER INSERT AS
BEGIN
SET NOCOUNT ON;
DELETE cf
FROM ContactInFolder AS cf
inner join Contact as co on cf.ContactId=co.Id
where co.[Name] like 'V3%'
END;

It practically deletes Contacts (whose name start with V3),that are added in the Static Folders. Does this added trigger may cause problems for the overall system ?

Thank you Sasori

Dmytro Vovchenko,

Hi Dmytro

Any Update ?

All the best Sasori

Show all comments