You need to sign in to do that
Don't have an account?

Field Update Trigger 2
To give you some background, Contact is the parent object and Concept_Email__c is the child object.
I am trying to write a tirgger that would update the
The arctics ID which is named "Concept_email_Arctics_ID_MSE__c" on Concept_Email__c object when it is changed
Below is the code snippet that I've started. Any help with fixing the trigger below will be appreciated.
As of now I am getting a syntactical error "Invalid field contact for sObject contact"
I am trying to write a tirgger that would update the
The arctics ID which is named "Concept_email_Arctics_ID_MSE__c" on Concept_Email__c object when it is changed
Below is the code snippet that I've started. Any help with fixing the trigger below will be appreciated.
As of now I am getting a syntactical error "Invalid field contact for sObject contact"
trigger UpdateArchticIDEmail on Contact (After Update) { for(Contact cont: Trigger.New) { //Select Arctics ID from Contact__c object Contact ArchID=[select Archtics_ID__c from Contact where id=:cont.Contact]; //Select Arctics ID from Concept_Email__c object list<Concept_Email__c> cec=[select Concept_email_Arctics_ID_MSE__c from Concept_Email__c WHERE Contact=:cont.id]; List<Concept_Email__c> listemail=new List<Concept_Email__c>(); for(Concept_Email__c uid:cec) { //Assign Updated Details from Contact__c object to Concept_Email__c Object uid.Concept_email_Arctics_ID_MSE__c=ArchID.Archtics_ID__c; listemail.add(uid); } update listemail; } }
open the field setting of Concept_Email__c object, find the api name of the field which Concept_Email__c is related to Contact (parent) object. replace contact__c with that api name.
All Answers
"Invalid field contact for sObject contact"
Your code doesn't meet the salesforce best practice, you should not use SOQL query inside the for loop.
Try the below code I strongly recommend you to take a look into the trailhead modules to learn about apex trigger and other custmozation topic - https://developer.salesforce.com/trailhead
Thank you very muh for the suggestion and for enlightening me on the best practice. I ran the code you sent me and I got an "unexpected token select" error on line 4. Is it because the select should go inside brackets?
Thank You've both. I whole heartledly appreciate your contributions. Both of your code samples have the same Variable does not exist Contact__c.Id error on Line 6
What could possibly be wrong here?
open the field setting of Concept_Email__c object, find the api name of the field which Concept_Email__c is related to Contact (parent) object. replace contact__c with that api name.