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

Help with Triggrer
Hello,
I have the following problem: I need to capture the number of minutes that the User was not a case to answer. I used the following logic in triggrer below:
if( (casesSLA[0].Tempo_Atendimento__c == 0)&&(casesSLA[0].Disposicao_imediata__c != null)){ casesSLA[0].Tempo_Atendimento__c = Math.floor((casesSLA[0].LastModifiedDate.getTime () - casesSLA[0].CreatedDate.getTime ())* 0.00001666666666666667 ); }
But she is a triggrer before update, then the User have to save twice the record so that it can capture time. When reading the documentation, I found that with triggre after update is not possible to perform DML operations.
Anybody know any other way so that I can perform this calculation without forcing the User to save twice the record?
thank you
In an after trigger, you just create a new record using the ID of the record you want to update.
for example, in an after trigger.
List<Lead> leadstoupdate = new List<Lead>();
for (Lead L : trigger.new){
Lead newlead = new Lead();
newlead.Id = L.Id;
newlead.OtherField__c = 'Hi';
leadstoupdate.add(newlead);
}
if (leadstoupdate.size() > 0){
update leadstoupdate;
}