You need to sign in to do that
Don't have an account?
Bryan Gordon
trigger sending email isn't showing trigger values
I have a trigger that fires off when a field called "FIMS_FundID__c" is updated. code looks like this:
trigger Z_TDF_TaskOnUpdate on Task (after update) {
if(trigger.isUpdate){
for(Task t : Trigger.new){
Task oldTask = Trigger.oldMap.get(t.Id);
if ( t.FIMS_FundID__c != oldTask.FIMS_FundID__C)
{
String userEmail = 'bgordon@dallasfoundation.org';
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] tmp = new String[]{'bgordon@dallasfoundation.org'} ;
mail.setToAddresses(tmp);
mail.setInReplyTo('noreply@dallasfoundation.org');
mail.setSenderDisplayName('Salesforce CRM Notification');
mail.setSubject('ID CHANGED for record ' + t.FIMS_ID__c );
String body = 'The Fund ID changed on activity record # ' + t.FIMS_ID__c + ' from ' + oldTask.FIMS_ID__c + ' to ' + t.FIMS_ID__c + '.';
mail.setPlainTextBody(body);
Messaging.sendEmail(new Messaging.SingleEMailMessage[]{mail});
}
}
}
}
When the field is updated, the email is sent, but the values are "null"
So the subject reads: ID CHANGED for record null
and the body of the email reads: The Fund ID changed on activity record # null from null to null.
does anyone know why the null values appear? If I use "t.Id" or oldTask.Id, they show up in the email correctly, but none of the other fields do.
trigger Z_TDF_TaskOnUpdate on Task (after update) {
if(trigger.isUpdate){
for(Task t : Trigger.new){
Task oldTask = Trigger.oldMap.get(t.Id);
if ( t.FIMS_FundID__c != oldTask.FIMS_FundID__C)
{
String userEmail = 'bgordon@dallasfoundation.org';
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] tmp = new String[]{'bgordon@dallasfoundation.org'} ;
mail.setToAddresses(tmp);
mail.setInReplyTo('noreply@dallasfoundation.org');
mail.setSenderDisplayName('Salesforce CRM Notification');
mail.setSubject('ID CHANGED for record ' + t.FIMS_ID__c );
String body = 'The Fund ID changed on activity record # ' + t.FIMS_ID__c + ' from ' + oldTask.FIMS_ID__c + ' to ' + t.FIMS_ID__c + '.';
mail.setPlainTextBody(body);
Messaging.sendEmail(new Messaging.SingleEMailMessage[]{mail});
}
}
}
}
When the field is updated, the email is sent, but the values are "null"
So the subject reads: ID CHANGED for record null
and the body of the email reads: The Fund ID changed on activity record # null from null to null.
does anyone know why the null values appear? If I use "t.Id" or oldTask.Id, they show up in the email correctly, but none of the other fields do.
What is the field type of FMIS_ID__c? Is it a formula?
All Answers
What is the field type of FMIS_ID__c? Is it a formula?
Good catch on the fields in the email body being different.
it turns out that we don't get this value until Salesforce syncs with out foundation mgmt software....which explains why it's null. When the sync occured, the value populated.
I guess it helps to talk things out :D
Thanks
If you do not mind, please pick a "Best Answer" (even if it's your own respsonse) to remove this from the unsolved queue.