• Jyoti Singh
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies

Hi

I am using trigger to create task for a case.Using upsert .everytime user saves case for the first time everything else trigger is doing are performed ,but task creation.While updating that record task gets created .can anyone help PLS.?

 

Using code

 

 if(someCondition){
               case1.Submit_Date__c = date.Today();
               case1.Status = 'Submitted';
               dateTime openedDate = case1.Actual_Date_Opened__c;
               dateTime finalDueDate =openedDate.addDays(7);
               List<User> userIdList =[Select id from User where Email = : 'fjkhfrj@jfjd.com'];
               
               Task tsk = new Task(whatID = case1.ID, Ownerid =userIdList[0].id, Subject = 'XYZ', ActivityDate = finalDueDate.date() , IsReminderSet = true, recordTypeId = 'XYZ');
               tasks.add(tsk);
             } 

if(tasks != null && tasks.size() > 0){
               upsert  tasks;
            }

Hi


I am creating tasks by trigger using code: Can anyone suggest ,How can I  create Tasks with a specific record type by trigger? using this code?

Task tsk = new Task(whatID = ID, Ownerid =user.id, Subject = 'XYZ', ActivityDate = DueDate.date() , IsReminderSet = true);
tasks.add(tsk);

Hi

I am using trigger to create task for a case.Using upsert .everytime user saves case for the first time everything else trigger is doing are performed ,but task creation.While updating that record task gets created .can anyone help PLS.?

 

Using code

 

 if(someCondition){
               case1.Submit_Date__c = date.Today();
               case1.Status = 'Submitted';
               dateTime openedDate = case1.Actual_Date_Opened__c;
               dateTime finalDueDate =openedDate.addDays(7);
               List<User> userIdList =[Select id from User where Email = : 'fjkhfrj@jfjd.com'];
               
               Task tsk = new Task(whatID = case1.ID, Ownerid =userIdList[0].id, Subject = 'XYZ', ActivityDate = finalDueDate.date() , IsReminderSet = true, recordTypeId = 'XYZ');
               tasks.add(tsk);
             } 

if(tasks != null && tasks.size() > 0){
               upsert  tasks;
            }

Hi


I am creating tasks by trigger using code: Can anyone suggest ,How can I  create Tasks with a specific record type by trigger? using this code?

Task tsk = new Task(whatID = ID, Ownerid =user.id, Subject = 'XYZ', ActivityDate = DueDate.date() , IsReminderSet = true);
tasks.add(tsk);