i've searched for info but still can't figure out why this is happening. I'm also at the moment with a case open on salesforce and me&support are trying to figure out what is happening.
As you know salesforce is programmed to send an email notification to the task owner when it is created (only if you have this feature enabled, which it is by default). We've activated all the features that you need to recive the mails (actually the users recieve some times the mails , sometimes not).
The weird thing about this is that the task is created all the times correctly but the emails isn't sent sometimes(which is suposed to be an automated SF process).
This is the code where we create the task (I didn't write it).
public void notifySales (Map<Id,Id> recordUser, Boolean alreadyAssigned){
Map<Id,Task> auxController = new Map<Id,Task>();
for(Id iter : recordUser.keySet()){
if(String.valueOf(recordUser.get(iter)).startsWith('005')){
if(!auxController.containsKey(recordUser.get(iter))){
auxController.put(recordUser.get(iter), new Task(OwnerId = recordUser.get(iter),
ActivityDate = System.today(),
IsReminderset = true,
Type = 'Record Assignment',
reminderDatetime = (system.now()).addSeconds(10),
Did_you_speak_with_CFO__c = 'No',
WhatId = (String.valueOf(iter).startsWith('001'))?iter:null,
WhoId = (String.valueOf(iter).startsWith('00Q'))?iter:null,
Subject = (alreadyAssigned)?label.InboundSubjectII : label.InboundSubject,
Description = 'Records to review :\r \r https://eu2.salesforce.com/'+String.valueOf(iter)));
}else{
auxController.get(recordUser.get(iter)).Description += '\r https://eu2.salesforce.com/'+String.valueOf(iter);
}
}
}
Database.SaveResult[] sRList = Database.insert(auxController.values(), false);
for(Database.SaveResult sR : sRList){
if(!sR.isSuccess()){
for(Database.Error err : sR.getErrors()){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'A notification failed due to'+err.getMessage()+'.'));
}
}
}
}
Another thing I found is that when the status of the Task is 'Not completed' the mails isn't sent and when it's completed the user recieved the mail.
Why is this happening? How could I solve it?