• Deepika G P
  • NEWBIE
  • 50 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 18
    Replies
Hi All,

I have code written on a project schedule object. When i run this code it is throwing "non-selective query against large object type(more than 200000 rows)...." error.
When I debug it the query it is fetching one record only.Could any one help me on this please

 if(trigger.IsAfter){
    if(trigger.isInsert || trigger.isUpdate){
        list<Task>Tasks=new list<Task>();                
        for(Project_Schedule__c PSOne:trigger.new){
           if(PSOne.Assigned_To_User__c!=null){
                user u=[select id,name from user where id=:PSOne.Assigned_To_User__c limit 1];                      
                 project__c p=[select id,name,Due_Date__c,Priority__c from project__c where id=:PSOne.Project__c limit 1];
                string s=(string)PSOne.Name;
                list<task>TskList= new List<Task>();                            
                list<task> etask =[select id,Project_Schedule_Name__c FROM Task WHERE Project_Schedule_Name__c =: PSOne.id];-----IT IS THROWING ERROR ON THIS LINE.
                system.debug('88888'+etask);
                system.debug('77777'+etask.size());
                 if(PSOne.phase__c!=null && psone.Task_Completed__c ==false && etask.size()==0 ){
                 {                      
                        Task Tsk=new Task(WhatId=P.id, OwnerId=u.id, Status='Not Started', ActivityDate=PSOne.actual_date__c, Priority='Normal',                          Description=PSOne.comments__c,Subject=PSOne.Phase__c,project_schedule_Name__c=PSOne.Name);
                        
                            Tasks.add(Tsk);                          
                      }
                      
                      if(trigger.isUpdate)
                      {                                          
                            for(Project_Schedule__c  oldProj: trigger.old){
                                if((oldProj.Actual_Date__c != PSOne.Actual_Date__c) && etask.Size()>0){
                                    for(Task t : etask){
                                    t.ActivityDate = PSONE.Actual_Date__c;
                                    tasks.add(t);
                    }
                }

 
Hi have an parent object project and child object project schedule . When the assigned to is changed to other user email needs to be sent for that i have written trigger below is the bit of that code. Now i want to pull the field values from project ,the trigger is written on project schedule.
When i try to pull the values i am getting null eg:Project:'+ PSOne.Project__r.Name ='null '
Can anyone help me on this please?

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    User current_user=[SELECT Email FROM User WHERE Id= :UserInfo.getUserId()] ;
                    String emailfromAddr = current_user.Email;
                    String emailtoAddr = PSOne.Assigned_To_User__c;
                    list<string> listmail= new list<string>();
                    listmail.add(emailfromaddr);
                    listmail.add(emailtoaddr);
                    mail.setToAddresses(listmail);
                    mail.setSubject(PSOne.Phase__c+' record is assigned to you  ' + PsOne.Name);  
                    mail.setPlainTextBody('To:'+ emailtoAddr +  '\n has made an change the following Task:'+  
                    '\n Subject:'+ PsOne.Phase__c+ '\n Project:'+ PSOne.Project__r.Name +'\n Due Date:'+PSOne.Project__r.Due_Date__c+'\n                                Priority:'+ PSOne.Project__r.Priority__c+
                    '\n For more details click the link below:{0}' );
                    system.debug('33333333'+ PsOne.Project__r);
                    Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
I have an Custom Object 'Customer participation' and Task is created for this object, now when I send an email from the related list with the subject as executive ,a field on task object should be inserted with an value. I have created a trigger but the trigger is working on all the objects. but i want it to work only on the emails of 'Customer participation'. Could anyone help me on this please.I am begineer in salesforce. 

trigger updatetaskoriginfield on Task (before insert, before update)
 {
     if(trigger.isBefore)
     {
            for(Task tsk: trigger.new)
            {
                 String test=tsk.subject;
                 set<string> a=new Set<string>{'executive','Executive'};
                 set<string> b=new Set<string>{'award','Award'};
                 List<String> lsttest=test.split(' ');
                 for(String s: lsttest)
                 {
                     if(a.contains(s))
                     {
                           tsk.Task_Origin__c='Executive Summary';
                     }
                     else if(b.contains(s))
                     {
                           tsk.Task_Origin__c='Award Notification';
                     }
                }
             }  
     }     
}
I have an Custom Object 'Customer participation' and Task is created for this object, now when I send an email from the related list with the subject as executive ,a field on task object should be inserted with an value. I have created a trigger but the trigger is working on all the objects. but i want it to work only on the emails of 'Customer participation'. Could anyone help me on this please.

trigger updatetaskoriginfield on Task (before insert, before update)
 {
     if(trigger.isBefore)
     {
            for(Task tsk: trigger.new)
            {
                 String test=tsk.subject;
                 set<string> a=new Set<string>{'executive','Executive'};
                 set<string> b=new Set<string>{'award','Award'};
                 List<String> lsttest=test.split(' ');
                 for(String s: lsttest)
                 {
                     if(a.contains(s))
                     {
                           tsk.Task_Origin__c='Executive Summary';
                     }
                     else if(b.contains(s))
                     {
                           tsk.Task_Origin__c='Award Notification';
                     }
                }
             }  
     }     
}

Hello most excellent Apex development community-

 

I'm looking for an example of how you would go about assigning a task to a related user on a record who is NOT the owner of the record when certain conditions apply.  If anybody could help with this challenge, I would certainly appreciate it!

 

conditions would be

 

Record.Stage is Stage2 AND field X is complete, assign a Task with subject "Please make phone call within 24 hours" to a RELATED USER (Record.Related_User__c).

 

Thanks,

Aaron