The below Apex code is used to update a field(Comments__c) in Member__c Object,
where Marital__Status and Comments__c are fields n Member__c object.
Code:
trigger commentsUpdate on Member__c (before Insert,before update)
{
for(Member__c member : Trigger.new)
{
if(member.Marital_Status__c != '')
{
member.Comments__c = member.Marital_Status__c;
}
else
{
member.Comments__c = 'No comments';
}
}
}
trigger.isInsert is true when a new record is created and inserted.
trigger.isUpdate is true when an existing record is modified.
where Marital__Status and Comments__c are fields n Member__c object.
Code:
trigger commentsUpdate on Member__c (before Insert,before update)
{
for(Member__c member : Trigger.new)
{
if(member.Marital_Status__c != '')
{
member.Comments__c = member.Marital_Status__c;
}
else
{
member.Comments__c = 'No comments';
}
}
}
trigger.isInsert is true when a new record is created and inserted.
trigger.isUpdate is true when an existing record is modified.
No comments:
Post a Comment