You need to sign in to do that
Don't have an account?
EvertonSzekeres
addError "FIELD_CUSTOM_VALIDATION_EXCEPTION"
I'm trying to deploy this trigger:
I don't want to close my cases with tasks opened.
It works fine, but when I will deploy I get this error message "Failure Message: "System.DmlException: Update failed. First exception on row 0 with id 500U0000009hsErIAI; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Você não pode fechar um chamado com tarefas abertas. "Abertura de vaga - Aprovar vaga" está aberta. Verificar com CP7 Diretoria: []", Failure Stack Trace: "Class.Email_abertur..."
I thought is because I have this another trigger:
I found the problem, but I don't have any idea what I have to do to deploy my trigger "NaoFechaChamado".
trigger NaoFechaChamado on Case (after update) { Set <id> ids = new Set <id> (); for (Case c: trigger.new){ if (c.status=='Fechado'){ ids.add(c.id); } } for (Case c: trigger.new) { if(ids.size()>0){ for(Task t : [SELECT Id, WhatId, owner.name, subject FROM Task WHERE isclosed=false AND (Not subject like '%Fech%') AND whatid IN: ids]){ if(c.status_do_processo__c != 'Extinto'){ c.addError('Você não pode fechar um chamado com tarefas abertas. "'+t.subject+'" está aberta. Verificar com '+t.owner.name+''); } } } if(ids.size()>0){ for(Task t : [SELECT Id, WhatId, owner.name, subject FROM Task WHERE isclosed=false AND (subject like '%Fech%') AND whatid IN: ids]){ if(c.status_do_processo__c != 'Extinto'){ t.status = 'Concluído'; update t; } } } } }
I don't want to close my cases with tasks opened.
It works fine, but when I will deploy I get this error message "Failure Message: "System.DmlException: Update failed. First exception on row 0 with id 500U0000009hsErIAI; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Você não pode fechar um chamado com tarefas abertas. "Abertura de vaga - Aprovar vaga" está aberta. Verificar com CP7 Diretoria: []", Failure Stack Trace: "Class.Email_abertur..."
@isTest (seeAllData=true) public class Email_abertura_de_vaga_test { static testMethod void myUnitTest001() { Case ca = new Case (); ca.Func_abertura_chamado__c = 'EVERTON GOMES'; ca.motivo__c='Abertura de vaga'; ca.subject='test'; ca.Description='test test'; ca.resposta__c=null; ca.Nome_atendimento__c='Asassa'; ca.N_veis__c='Auxiliar'; ca.Meios_de_divulga_o__c='Asdfgh'; ca.Candidatos_agendados__c=15; ca.Candidatos_avaliados__c=9; ca.Candidatos_pr_selecionados__c=1; insert ca; ca.resposta__c='teste'; ca.Func_abertura_chamado__c = 'ALAN BRONER'; ca.motivo__c='Abertura de vaga'; ca.Nome_atendimento__c='Teste'; ca.N_veis__c='Recepcionista'; ca.Meios_de_divulga_o__c='TEste'; ca.Candidatos_agendados__c=12; ca.Candidatos_avaliados__c=10; ca.Candidatos_pr_selecionados__c=2; ca.In_cio__c= Date.today(); update ca; } }
I thought is because I have this another trigger:
trigger CriarTarefaCase_Abertura_de_vaga on Case (after insert) { List<Task> tasks = new List<Task>(); List<Case> cse = Trigger.new; for (Case c : cse){ if (c.motivo__c == 'Abertura de vaga' && c.status != 'Fechado'){ Task tsk = new Task (whatID = c.ID, Subject = 'Abertura de vaga - Aprovar vaga', ActivityDate = Date.today(), Ownerid = '005U0000000FDE9'); tasks.add(tsk); } } insert tasks; }
I found the problem, but I don't have any idea what I have to do to deploy my trigger "NaoFechaChamado".
It seems their is a validation rule in target org where you are deploying, and your record data is not complying with that. I would suggest examine the target org for validation rules, and fix your test data accordingly. Read more here on official salesforce help : http://help.salesforce.com/apex/HTViewSolution?id=000002540&language=en_US (http://help.salesforce.com/apex/HTViewSolution?id=000002540&language=en_US)
Because I deactivated all of them to see if this is the cause, but it doesn't.
I don't know what to do to made this test class understood that all the tasks are already closed.