You need to sign in to do that
Don't have an account?
Update changes in rich text area field on Account to rich text area on Contact
I have created a custom rich text area field (called General Information) on the Account object and am successfully populating a rich text area field (also called General Information) on the Contact object. I would like:
- To update the Contact General Information field anytime the Account General Information field is changed.
- I would also like the field on the Contact object to remain editable--this value will eventually be populated on the Opportunity
- Additionally, I would like ALL contacts associated with the Account to inherit the Account General Information value.
https://help.salesforce.com/articleView?id=000213419&language=en_US&type=1
Here Account is the parent object and Contact is the child object.
Thanks,
Balayesu
All Answers
https://help.salesforce.com/articleView?id=000213419&language=en_US&type=1
Here Account is the parent object and Contact is the child object.
Thanks,
Balayesu
To achieve this use a trigger, like this,
Thanks,
Balayesu
- What should I replace ID with?
- What should I replace Phone with?
- I think I have all of the other variables identified correctly
Sorry I'm not an experienced developer, so I'm still a little stuck.trigger acctrigger on Account(after update) {
Id=[SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId()].Id;
for(Account a:trigger.old){
if(Trigger.oldMap.get(a.Id).GeneralInformation__c != Trigger.newMap.get(a.Id).GeneralInformation__c){
a.Last_Modified_By__c=Id;
a.Last_Modified_On=System.datetime.now();
}
}
}
I forget to define Id in the code. you can remove phone in the sql statement, just define ID like,
Thanks,
Balayesu
trigger acctrigger on Account(After Update) {
Id Id=[SELECT Id FROM User WHERE Id = : UserInfo.getUserId()].Id;
for(Account a:trigger.old){
if(Trigger.oldMap.get(a.Id).General_Information__c != Trigger.newMap.get(a.Id).General_Information__c){
a.Last_modified_by__c=Id;
a.Last_modified_on__c=System.datetime.now();
}
}
}
It all compiles perfectly, but when I modify the General Information field I get the following error:
Error:Apex trigger acctrigger caused an unexpected exception, contact your administrator: acctrigger: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.acctrigger: line 5, column 1
I tried removing the "a.", the "__c), etc. with no luck. Do you see my syntax problems? I'm assuming it doesn't like line 6 either but it doesn't get that far.
Thanks again,
Steve