function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Everton CP7Everton CP7 

Create task in same related to

Hi there,

 

I made a code to create a task when another task have fotos_encontradas__c == 'NÃO'.

The code works fine, but whatid is not the same.

 

How I made my task open in same whatid?

 

 

trigger CriarTarefa_Pendencia_Duomind_Enviar_novamente_as_foto on Task (after update) {

    List<Task> task = new List<Task>();
    for (Task newTask: Trigger.New)
        if (newtask.fotos_encontradas__c == 'NÃO' && newtask.subject == 'Pendência Duomind' && newtask.status <> 'Concluído'){
                 task.add (new Task(
                     Subject = 'Pendência Duomind - Enviar novamente as fotos',
                     Status = 'Não iniciado',
                     ActivityDate = Date.today(),
                     OwnerId = '005U0000000EtIH'));   
         }
   insert task;
 }

Thanks ! 

Best Answer chosen by Admin (Salesforce Developers) 
colemabcolemab

I don't see where you are trying to set the what ID at all.

 

Perhaps something like this is what you need:  WhatID = :NewTask.WhatID

All Answers

colemabcolemab

I don't see where you are trying to set the what ID at all.

 

Perhaps something like this is what you need:  WhatID = :NewTask.WhatID

This was selected as the best answer
Everton CP7Everton CP7

I don't believe  !!!

 

I forgot this...

 

Thanks Colemab !

 

 

colemabcolemab

No problem.  Don't forget to give Kudos for correct answers and helpful posts :-)