+ Start a Discussion

copy contact id into a custom object

I have an object called Student__c with a field 'Related_Contact__c', I have written a trigger which creates a Person account when a new record is created on Student__c.  After the Person Account is created, I want to copy the PERSONCONTACTID or contactid back into the Student__c object, can anybody help to write a trigger .

When creating a person account, I am copying the ID of from Student__c to person account 'Salesforce_id_from_Student__c and Name field into Student_id_from_student__c
Pasan   EeriyagamaPasan Eeriyagama
Is this what you're looking for,
Account a = [Select PersonContactId From Account Where Id = :AccountId];

Based on the information I provided I need to insert the personcontactid  from Account into the Student__c object field name is 'Related_Contact__c' (look up field from Student__c to Account)