You need to sign in to do that
Don't have an account?
rathore_1987
Want Help in Trigger !!!!!!!!!!!
Actully i want to create a trigger in SFDC which will update or Insert the recordes in custom object so i just want the query to update n Insert.if some one can help ?
hi
rathore_1987
very simple trigger code to Update Account Custom FIeld when New Contact is Created
"
trigger AfterCreateOrUpdateContact on Contact (after insert,after update) {
if(ConfigUtilController.getAfterCreateOrUpdateContact()){
List < Id > contactIds = new List < Id >();
List < Id > contactAcIds = new List < Id >();
for ( Contact c : Trigger.New ) {
contactIds.add( c.Id );
contactAcIds.add( c.AccountID );
}
List < Account > accountsOfContacts = [select a.ID,
a.Name,
a.Default_Contact__C,
a.Account_Key__c,
a.AccountNumber
from Account a
where a.Id in : contactAcIds];
Map < Id ,Account > accmap = new Map < Id , Account >();
for ( Account a : accountsOfContacts ) {
accmap.put( a.Id, a);
}
List < Account > accToUpdate = new List < Account >();
for(Contact c: Trigger.New) {
Account ac = accmap.get( c.AccountID );
if ( ac == null ) {
continue;
}
If (c.Default__c == true){
ac.Default_Contact__C = c.ID;
accToUpdate.add( ac );
}else if ( ac.Default_Contact__C == null ) {
ac.Default_Contact__C = c.ID;
accToUpdate.add( ac );
}
}
upsert accToUpdate;
}
}
"
hope this help for you
regards,
Hitesh N. Patel
Thanx let me try
can u help me in mine trigger i can send u that one