• Nishant Kumar 107
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
I am getting below exception
Execution of BeforeInsert caused by: System.SObjectException: DML statement cannot operate on trigger.new or trigger.old: Class
I create a class which insert task for account object while creating task for a Lead object, below i hardcoded the account whatId. I created trigger for Task and call CreateTaskInAccount.createTask() from trigger, but its not happening like so.
Please share your feedback.

public class CreateTaskInAccount
{
 public void createTask(List<Task> TaskFromTrigger)
  {
  
    Account targetWhatId= [SELECT a.Id FROM Account a where a.Name='NishantAccount'];
    
    List<Task> tskList= new List<Task>();
    
    for(Task varTask: TaskFromTrigger)
    {
      Task tsk= new Task();
      
      tsk=varTask;
      tsk.WhatId=targetWhatId.Id;
            
                  
      tskList.Add(tsk);
    }
  
    Database.Insert(tskList);
  }
}
------------------------------------
trigger CreateTaskInAccount on Task (before insert, before update) {

  List<Task> lTask = new List<Task>();
  
    
  CreateTaskInAccount objAccount=new CreateTaskInAccount();
  objAccount.createTask(Trigger.new);
}

Tanks in advance
Couple of questions:

a. How could i add custom user field for "Next Automated Approver Determined By"  while configuring Approval process manually.

b. How could i handle dropdown selected index change for custom object, I have a picklist on custom object and i need to perform some action on its selected index change. Does it possible through visual force page or i need to write apex code. Kindly suggest or share any link from where i can get reference.

Regards,
Nishant
 
I am getting below exception
Execution of BeforeInsert caused by: System.SObjectException: DML statement cannot operate on trigger.new or trigger.old: Class
I create a class which insert task for account object while creating task for a Lead object, below i hardcoded the account whatId. I created trigger for Task and call CreateTaskInAccount.createTask() from trigger, but its not happening like so.
Please share your feedback.

public class CreateTaskInAccount
{
 public void createTask(List<Task> TaskFromTrigger)
  {
  
    Account targetWhatId= [SELECT a.Id FROM Account a where a.Name='NishantAccount'];
    
    List<Task> tskList= new List<Task>();
    
    for(Task varTask: TaskFromTrigger)
    {
      Task tsk= new Task();
      
      tsk=varTask;
      tsk.WhatId=targetWhatId.Id;
            
                  
      tskList.Add(tsk);
    }
  
    Database.Insert(tskList);
  }
}
------------------------------------
trigger CreateTaskInAccount on Task (before insert, before update) {

  List<Task> lTask = new List<Task>();
  
    
  CreateTaskInAccount objAccount=new CreateTaskInAccount();
  objAccount.createTask(Trigger.new);
}

Tanks in advance

Hi Friends,

 

IMAGE(
CASE(Marked_for_deletion__c,
"FALSE", "/img/samples/light_green.gif",
"TRUE", "/img/samples/light_red.gif",
"/s.gif"),
"Marked For Deletion Flag")

 

 

Here Marked_for_deletion__c is a checkbox. so i used TRUE and FALSE in the case functions.

But its showing error Like " Error: Incorrect argument type for function CASE(). "

 

Kindly help me out in this.

 

Thanks.