Costum Fuction to interactions

Costum Fuction to interactions

Hello,

I've created a new module (Leads interactions) this new module will have all the forms that my leads filled in.

This new module haves a search field that need to be filled with the associated lead, and i want this to be automatic.

So, basically, i need that when i create a new lead interaction a function runs and searches if the email i inserted on the lead interaction exists on the leads module (if theres any record with that email), if it exists then it will fill the search field with the associated lead.

all this only comparing emails.

Thanks