+ Start a Discussion

I want to write a trigger on custom object(contact), to create a child record of it.

sceneria is as follow:
In cantact i have field called referred by email(contact emailid of other ).
I have created child object of contact as referral points.

Now i have create child record once referred by email field is updated.
but chalenge is i am getting emailId of referred contact, so i neet to get the contact name of that emailId  and then i should give points to him(reating childrecord).
I understand that you have a custom object - contact - there is a field in this custom object called referred by  which is populated by another contat's email address.
You wish to find that contact and create a child record for that contact..

You can try the following pseudocode:
1)Create an after insert/update trigger on Contact(custom object)
2)fetch the referred by email address field  and run a SOQL query to find the contact with the same email address
3)create the child record under that contact