You need to sign in to do that
Don't have an account?
Zach Bratcher
Need Help Writing my first trigger
I currently have a custom field on the Contacts Object called Field Lable: Colleague ID API Name: TargetX_SRMb__Colleague_ID__c that I need when it gets filled in to trigger and copy the data from Colleague ID field and add it to the Field Lable: SRM ETL ID API Name: TargetX_SRMb__SRM_ETL_ID__c on the Application Object
All Answers
trigger contactTrigger on Contact (before update) {
set<id> d= new set<id>();
list<application__c> lst= new list<application__c>();
map<id,contact> l= new map<id,contact>();
for(contact c:trigger.new){
if(c.CleanStatus != trigger.oldmap.get(c.id).CleanStatus && c.CleanStatus=='test'){
d.add(c.id);
l.put(c.id,c);
}
if(d.size()>0){
for(application__C c:[select id,TargetX_SRMb__SRM_ETL_ID__c from application__C where relationshipnameField=:d]){
c.TargetX_SRMb__SRM_ETL_ID__c = l.get(c.relationshipid(contactrelated)).TargetX_SRMb__Colleague_ID__c;
lst.add(c);
}
if(lst.size()>0){
update lst;
}
}
}
}
for(application__C app:[select id,TargetX_SRMb__SRM_ETL_ID__c from application__C where relationshipnameField=:d]){
app.TargetX_SRMb__SRM_ETL_ID__c = l.get(app.relationshipid(contactrelated)).TargetX_SRMb__Colleague_ID__c;
lst.add(app);
}
trigger contactUpdateAppTrigger on Contact (before update) {
set<id> d= new set<id>();
list<application__c> lst= new list<application__c>();
map<id,contact> l= new map<id,contact>();
for(contact c:trigger.new){
if(c.CleanStatus != trigger.oldmap.get(c.id).CleanStatus && c.CleanStatus=='test'){
d.add(c.id);
l.put(c.id,c);
}
if(d.size()>0){
for(application__C app:[select id,TargetX_SRMb__SRM_ETL_ID__c from application__C where relationshipnameField=:d]){
app.TargetX_SRMb__SRM_ETL_ID__c = l.get(app.relationshipid(contactrelated)).TargetX_SRMb__Colleague_ID__c;
lst.add(app);
}
if(lst.size()>0){
update lst;
}
}
}
}
But now getting the error Error: Compile Error: Invalid type: application__c at line 4 column 5 which line 4 is list<application__c> lst= new list<application__c>();
Here is the link how you can find it https://help.salesforce.com/articleView?id=000007594&type=1
Thanks
Contact OwnerOwnerLookup(User)
Contact Record TypeRecordTypeRecord Type
Created ByCreatedByLookup(User)
ReplaceCampus TargetX_SRMb__Campus__c TX Recruitment Manager Picklist
CEEB Code TargetX_SRMb__ceeb_code__c TX Recruitment Manager Text(6)
Citizenship hed__Citizenship__c HEDA Picklist
Citizenship TargetX_SRMb__Citizenship__c TX Recruitment Manager Picklist
Colleague ID TargetX_SRMb__Colleague_ID__c TX Recruitment Manager Text(255) (External ID) (Unique Case Insensitive)
College TargetX_SRMb__College__c TX Recruitment Manager Picklist
Community User TargetX_Base__Community_User__c TargetX Base Text(25)
Concentration TargetX_SRMb__Concentration__c TX Recruitment Manager Picklist
Contact Owner Home Campus Contact_Owner_Home_Campus__c Formula (Text)
Country of Origin hed__Country_of_Origin__c HEDA Picklist
Country of Permanent Residence TargetX_SRMb__Country_of_Permanent_Residence__c TX Recruitment Manager Text(255)
Current Address hed__Current_Address__c HEDA Lookup(Address) Account
Current Campus Current_Campus__c Picklist
Current County or Parish TargetX_SRMb__Current_County_or_Parish__c TX Recruitment Manager Text(50)
Current Major Current_Major__c Text(250)
if(c.CleanStatus != trigger.oldmap.get(c.id).CleanStatus && c.CleanStatus=='test'){
Must be from different object make sure you use it from right object
Thanks
Thanks for the Help but I was able to find a way through the Process builder to get it to work like I needed.
How do I go through and mark it as solved. I am not seeing anything that gives me the ability to do so.