You need to sign in to do that
Don't have an account?
Aam M
trigger to update contact when account record is updated
I want to write trigger to enable a checkbox in contact whenever its Account is modified(updated).
I'm not able to put the condition for Account updated or not! Can you guys provide the logic??
I'm not able to put the condition for Account updated or not! Can you guys provide the logic??
You should try this code .
Apex Trigger I hope it will help you.
Regards,
Akshay
Please mark my answer as a solution if it is helpful.
All Answers
Hi Mujahid,
Hope it will helps you :)
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
If I am not wrong,
You want when anyone will update the account then the checkbox will automatically check on contact.
Thanks,
Harshit garg
You should try this code .
Apex Trigger I hope it will help you.
Regards,
Akshay
Please mark my answer as a solution if it is helpful.
You can achieve it through Process Builder.
Create process on Account Object, You can specify entry condition on account record to qualification.
Update Child record.
You can update all Contact under that account (or). You can specify the condition on Contact record, and update the checkbox on it.
Thanks.
Otherwise, as Saravana suggested, go for Process builder since it is easy to maintain later stages. Process builder is designed to reduce the coding efforts required for various such small things, so use it.
--
Abhi
Regards,
Akshay
You want to update opportunity name same as account name. Please correct me if i am wrong.
Thanks,
Harshit Garg
8909685434
harshitgarg2591@gmail.com
Yes, but when Account Name is updated.
my current code is below:
Thanks.
1.Based on connect_america_account__c on account, make changes connect_america_account__c on contact
A. trigger will be written on account
2. Will it be before or after trigger?
A.After Trigger are used to perform logic on the related objects so it is after trigger
3. How are account and contact related ?
A.They are related based on accountid on contact
4. Which trigger context variable will be used?
update
FINAL CONCEPT
trigger UpdateConnectAmericaTrigger on Account (after update){
List<Contact> newCList = new List<Contact>();
Set<Id> setaccountId = new Set<Id>();
for(Account acc : Trigger.new)
{
if(acc.connect_america_account__c!=Trigger.oldMap.get(acc.id).connect_america_account__c
&& acc.connect_america_account__c == true
){
setaccountId.add(acc.id);
}
}
List<Contact> conlist =[Select id, connect_america_account__c,accountid from contact where accountid IN: setaccountId];
for(contact c: conlist){
c.connect_america_account__c = true;
newClist.add(c);
}
update newClist;
}
ABC Firm needs to make the service desk more productive. They have an idea to create Case Solutions as a reference guide for customers and service agents if any case resolution is accepted by the customer.
Create a custom object ‘Case Solution’ with fields Case Description, Resolution.
- Create a custom field ‘Accept Solution’ as a checkbox on Case object.
- Create a custom field ‘Resolution’ as a text area on Case Object.
- Whenever a case has the status ‘Closed’ and its ‘Accept Solution’ checkbox is selected; a new Case Solution record should be created.
please share code for this problem statement .
I think this can be acheived using Process Builder. Please correct me if I'm wrong
I am new in Salesforce, I got one requirement that is, when a trigger to update all the contacts " Mailing address" when the related account "shipping address" is changed. And count the number of times the shipping addressgets changed and store that in the "shipping change counters" integer field on account.
Could you please help me on this requriment.
Thanks in Advanced,
Gowri Lalapeta
8309864635
Gowri.lalapeta@gmail.com
Hope it will helps you :)
Apex class
//I want to write trigger to enable a checkbox in contact whenever its Account is modified(updated).
public class satish_practice7 {
public static void AfterUpdate_trigger(Map<Id,Account> oldMap,Map<Id,Account> newMap){
set<Id> Ids=new set<Id>();
for(Id I:oldMap.keyset()){
Account accOld=oldMap.get(I);
Account accNew=newMap.get(I);
if(accOld!=accNew){
Ids.add(I);
}
}
List<contact> conList=[select id, accountId from contact where AccountId in:Ids];
for(contact c:conList){
c.CheckBox__c=true;
}
update conList;
}
}
Trigger :-
trigger Account_trigge7 on Account (after update) {
satish_practice7.AfterUpdate_trigger(trigger.oldMap,trigger.newMap);
}