You need to sign in to do that
Don't have an account?

trigger
Hi
i need to write a trigger on contact that have a related list contactcommitments in contacts if that related records are there then i have is commitment field on contact it has to become true otherwise false .
can anyone help me out.
Hi,
Have you created the Contactcommitment as Custom Object??? If yes then you have to write the trigger on ContactCommitment object not on contact. Try the below code as reference (made changes accordingly):
Trigger UpdateContact on ContactCommitment__c (after insert)
{
List<Contact> con=[select id,Checkbox__c from contact where id=: trigger.new[0].contact__c];
if(Con.size() > 0)
{
Con[0].checkbox__c = true;
Update con;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
hi
i think you may be right can u jst explain me what this id refers to //id=: trigger.new[0].contact__c///
here contact__c means what here in my code i am getting error if i wrote like dat .
suggest me.
Hi Deepu,
You have to write your trigger in the related object.
contact__c indicates that this is the parent field.
id=: trigger.new[0].contact__c = means that you are getting the first new value id of the first record that will be entered upon population of the related object.
K its working when i added related records, but wen i deleted related records the checkbox is not unchecking .
can u suggest me for dat