You need to sign in to do that
Don't have an account?
rmranjith8881.3927046400771116E12
Trigger
Hi Everyone,
I have two custom fields(below) on opportunity where Record Type="Rec1"
Donor_nme__c(Text)
Donor_Mobile__c(phone).
I want to update these fields from contact.
Can any one help me out?
Thanks in advance?
I have two custom fields(below) on opportunity where Record Type="Rec1"
Donor_nme__c(Text)
Donor_Mobile__c(phone).
I want to update these fields from contact.
Can any one help me out?
Thanks in advance?
http://salesforce.stackexchange.com/questions/16886/trigger-based-on-record-type-to-show-the-result-as
now i made a trigger like this:
trigger updateContactinfo on Opportunity (before insert,before update) {
set<id> AccountIDSet = new set<id>();
map<id,contact> AccountContactMap = new map<id,contact>();
List<Opportunity> lstOppToUpdate=new List<Opportunity>();
RecordType rt = [SELECT Id,Name FROM RecordType WHERE Name = 'Feast Donor' Limit 1];
for(Opportunity opp1:Trigger.new){
if(opp1.RecordtypeId==rt.Id){
AccountIDSet.add(opp1.id);
//opp1.RecordType = [select Id from RecordType where Name = 'Feast Doner' and SobjectType = 'Opportunity '];
}
}
List<contact> TempLst = [select id,name,phone,Account.Name from contact where Id in : AccountIDSet];
for(Contact TempContactObj : TempLst)
{
AccountContactMap.put(TempContactObj.id, TempContactObj);
}
for(Opportunity opp: [Select AccountId, Donor_Nme__c, Donor_Mobile__c from Opportunity where AccountId IN: AccountContactMap.KeySet()]){
opp.Donor_Nme__c=AccountContactMap.get(opp.Id).Name;
opp.Donor_Mobile__c=AccountContactMap.get(opp.Id).phone;
lstOppToUpdate.add(opp);
}
update lstOppToUpdate;
}
It is saved fine,but when i create new opportunity or editing existing Opportunity it won't update the donor name and donor mobile no from contact.
Can you help me out?
Thanks in advance.