• Apex Estrategia
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies

Hi,

 

I created this trigger:

 

trigger CriarTarefa_Produtos_Cobranca on Task (after update) {

    List<Task> taskProd = new List<Task>();
    for (Task tt : Trigger.new)
    if (tt.subject == 'Cobrança - Problemas com produtos' && tt.status == 'Concluído' || tt.subject == 'Cobrança - Pergunta não solucionada' && tt.status == 'Concluído'){
                taskProd.add (new Task(
                         Subject = 'Cobrança - Questão solucionada?',
                         Status = 'Nenhum',
                         WhatID = tt.WhatID,
                         Description = tt.description,
                    	 OwnerId = '005U0000001KrXY',
                         ActivityDate = Date.today()));
 }

    for (Task tt : Trigger.new)
    if (tt.subject == 'Cobrança - Questão solucionada?' && tt.Quest_o_solucionada__c == 'SIM' && tt.status == 'Concluído'){
                taskProd.add (new Task(
                         Subject = 'Cobrança - Feche o chamado e notifique o formando',
                         Status = 'Nenhum',
                         WhatID = tt.WhatID,
                         Description = tt.description,
                    	 OwnerId = '005U0000001KrXY',
                         ActivityDate = Date.today()));
 }
    for (Task tt : Trigger.new)
    if (tt.subject == 'Cobrança - Questão solucionada?' && tt.Quest_o_solucionada__c == 'NÃO' && tt.status == 'Concluído'){
                taskProd.add (new Task(
                         Subject = 'Cobrança - Pergunta não solucionada',
                         Status = 'Nenhum',
                         WhatID = tt.WhatID,
                         Description = tt.description,
                    	 OwnerId = '005U0000000FrCz',
                         ActivityDate = Date.today()));
 }
                insert taskProd;
            }

 And my test class:

 

@IsTest(SeeAllData=true)
public class CriarTarefa_Pendencia_Duomind_test{
static testmethod void MyUnitTest(){
    
 
     User u = [select id from User where LastName='Marketing'];
      
     Case c = new Case (recordtypeid='012U000000011yC');
    
     Task tsk  = new Task(Status='Não iniciado', Priority='Normal', subject='- Iniciador do Fluxo -');
     insert tsk;
 
    tsk.Status = 'Concluído';
    update tsk;
}
}

 

My code coverage is in 74%.

What I'm missing here?

 

Any help?

 

Thanks !

Hi !

 

I create a trigger to close my case when I close one specific task.

 

trigger FechaTask_FechaCase on Task (after update) {

Task[] cse = Trigger.new;

    Set<ID> cseIds = new Set<ID>();
    for (Task t:cse)
      if (t.status == 'Completed' && t.subject == 'Baixar PP')
      cseIds.add(t.whatid);

      for (Case c : [select id, motivo__c, status from case where id in :cseIds for update])
      if (c.motivo__c == 'Solicitação de Pagamento'){
        c.status = 'Closed';
        update c;
      }
    }

 

And I got an error:

 

  • Corpo: Validation Error: Value is required
  • FechaTask_FechaCase: System.LimitException: Too many SOQL queries: 101

 

I don't know why this error appears just when I try to close the case.

If I update a regular field my trigger works.