• uma52551.3972270309784705E12
  • NEWBIE
  • 78 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 53
    Replies
HI All,

How to query if a particular USER has Enable chatter access using apex code(SOQL) what is the field that we need to query. Thanks in Advance
Hi Friends,

Trying to create a visualforce page to enter field values of one object. While we try to hit save it has to check if all fields are entered if not it has to open a window/page to display the missed fields and ask user to enter values there itself and save from that page/window.

I picked one object and 10 fields if 2 fields are not entered in the first page and user tries to hit save it has to open a window/page to show those two fields and user has to enter those fields in the second page/window and hit save. Then the record should be saved.

I wrote normal code which will save record when all fields are provided. Can Any one help me on this code!.

Thanks & Regards, 
Hi All,

Can any one help me in writting the VF page and custom controller to fetch data from different objects based on input field and update the records.

Ex: If there is a custom object called assginment__c then by giving a assginment name as input value on the VF page controller has to pick that record and load the  fields on VF page to edit and update those record values in salesforce. 
Same way the same VF page has to upadte the values of 5 different objects which are not related to each other. So for this I need Cutom controller. 

Please help me in writing this page and controller. Thanks in advance!!!
Hi Friends,

Here is my issue. Please advise me or help me.
I am having a field called Id_Generator__c which is autonumber field under object named custom_account__c. Now I have to write a trigger that will take this autonumber field and encrypt that field and then it has to send that encrypted value to the document I am sending out for signature(esignature) and then after signature the trigger has to get the key and decrypt that and have to store that value. Please let me know if you guys have any idea.

Thanks,
 
Hi All,

I need help on creating Apex trigger Here is the scenario:
I am having two objects 1. Account  2. Account Branch with a master detail relation ship where Account is Master.
Fields:
Account Branch ->  Branch_Status__c.
Account           ->  Status, Client_Id__c and rollup summary field that will calculate number of Branchs under that account called         No_Of_Branches__c

Now My trigger has to update Account status as follows:
If Client_Id__c = 'X' and No_Of_Branches__c = 0 then Status = 'Closed Prospect'
If Client_Id__c contains SAP or PAS and No_of_Branches__c = 0 then status = Active
If Client_Id__c contains SAP or PAS and No_Of_Branches__c !=0 and Branch_Status_c!=Cancel then status = Active
(Here Branch_Status__c is a field of child object and trigger has to check status of Branches and have to determine cancel if all are on cancel state or not)
If Client_Id__c contains SAP or PAS and No_Of_Branches__c !=0 and Branch_Status__c==cancel then status = Inactive
(Here Branch_Status__c is a field of child object and trigger has to check status of Branches and have to determine cancel if all are on cancel state or not)

Can any one help to frame the trigger. The trigger has to be on the child object.

Thanks,

 
 
Hi Friends,

Here I am trying to insert tasks from account using apex trigger. This is working for individual edits but if I am trying to update the accounts using data laoder it is inserting tasks for those 5 accounts instead it is inserting task for one account. Here is my trigger please let me know the how to make this trigger to work for bulk updates using data loader.

trigger TaskInsertTriggerOnAccount on Account (after update) {
    List <RecordType> rtList = [SELECT Id from RecordType where SobjectType='Account' and Name = 'BB' Limit 1];
    List <task> taskToInsert = new List <task> ();
     Set<Id> accountIds = new Set<Id>();

    for(Account acc:Trigger.New){
    if(acc.Agent_Id__c!=NULL&&acc.Contracting_Completed_Date__c==date.Today()&&acc.Contracting_Complete__c==True&&acc.RecordTypeId==rtList[0].Id&&acc.status__c=='Active'){
     accountIds.add(acc.Id);
      }
    }
    
    Map<Id,Bulk_Product__c> bulkProdMap = new Map<Id,Bulk_Product__c>();
    List<Bulk_Product__c> bulkProdList = [Select Id,Bulk_Code__c,Bulk_acc__c from Bulk_Product__c Where Bulk_acc__c IN :accountIds and Bulk_Code__c = 'CCM' Limit 1];
    for(Bulk_Product__c bk:bulkProdList ){
     if(ag.Bulk_Code__c!=NULL){
      bulkProdMap.put(bk.Bulk_acc__c,bk);
      }
     }
    List<RecordType> rtList1=[Select Id from RecordType where SobjectType = 'Task' and Name = 'BB Tasks' Limit 1];  
   List<Account>  accList = [select id,ownerId,Name,Agent_Id__c,Status__c,RecordtypeId from Account Where Id IN:accountIds and RecordTypeId=:rtList[0].Id Limit 1]; 
     for(Account acc:accList){
     if((trigger.isUpdate)&&bulkProdMap.containsKey(acc.Id)){
     task t1 = new task ();
     t1.RecordTypeId = rtList1[0].Id;
     t1.ActivityDate = Date.today()+2;
     t1.Status = 'Not Started';
     t1.Description = 'New Contract----------------. Please make personal contact with the agent';
     t1.Subject = 'New Contracted Follow Up';
     t1.OwnerId = acc.ownerId;
     t1.WhatId = acc.Id;
     t1.Priority = 'High';
     taskToInsert.add(t1);
    
     }
     
  if(taskToInsert.Size()>0){
       insert taskToInsert;
       }
 
    }      
 }
Hi All,

Can any one guide me how to write a trigger on Account that has to create a task record (Only one record) and then send an email notification to the person who is in assgined to field. I wrote an after update trigger but it is creating multiple task records when ever i am editing account page for any reason.
Thanks!
Below two triggers on Event and Task is to update their Subjet into a custom field of an Opportunity based on thier Activity dates.
For Ex: If Event Activity Date < Task Activity Date then Next_Activity__c should be updated with subject of Event and vice versa.  But these triggers are failing to update subject when I am trying to delete last task/event. Can any one please test these triggers and help me in knowing my issue. 
Note: I have created a custom field called Next_Activity_date__c on Opportunity to update tasks date that got updated.
trigger UpdateOppNextActivtyTrigger on Task (after insert,after update) {
  List<Id> idSet = new List<Id>();
   
  for (Task att: Trigger.new) {
     if ((att.WhatId + '').startsWith('006')) {
       idSet.add(att.WhatId);
      }
   }
   List<RecordType> rtList = [Select Id,Name from RecordType where SObjectType = 'Opportunity'and Name = 'van Wagenen' Limit 1];
   List<Opportunity> opptyList = [Select RecordTypeId,Next_Activity__c,Next_Activity_Date__c,Next_Activity_Event_Date__c, (select id,RecordType.Name,Status, subject,ActivityDate from Tasks Where isClosed =false order by ActivityDate ASC)from Opportunity where id in : idSet and recordTypeId = :rtList.get(0).Id ];
   List<Opportunity> updateList = new List<Opportunity> ();
  if(!opptyList.isEmpty()){
   for (opportunity opp: opptyList){
       if (!opp.Tasks.isEmpty() &&opp.Tasks.get(0).Subject != null) {         
                      System.debug('Subject on Opportunity before task update:'+opp.Next_Activity__c);
                      System.debug('Subject on Task before update:'+opp.Tasks.get(0).Subject);
                      System.debug('Next Activity Date on Opportunity before update:'+opp.Next_Activity_Date__c);
                      System.debug('Next Activity Date on Task before update:'+opp.Tasks.get(0).ActivityDate);
                 if (opp.Next_Activity__c != opp.Tasks.get(0).Subject) {
                      opp.Next_Activity__c = opp.Tasks.get(0).Subject;
                      opp.Next_Activity_Date__c = opp.Tasks.get(0).ActivityDate;
                      System.debug('Subject on Opportunity after update:'+opp.Next_Activity__c);
                      System.debug('Subject on Task after update:'+opp.Tasks.get(0).Subject);
                      System.debug('Next Activity Date on Opportunity after update:'+opp.Next_Activity_Date__c);
                      System.debug('Next Activity Date on Task after update:'+opp.Tasks.get(0).ActivityDate);
                      
                      
                     }
                    }  updateList.add(opp);                   
  }
 }
  if (!updateList.isEmpty()){  
   update updateList;
   }
 }


---------------------------------------------------------------------------------------------------------------------------------------------
trigger UpdateOppEventNextActivityTrigger on Event (after insert,after update,after delete) {
 Set<Id> oppIds = new Set<Id>();
  
      List<Event> evts;
  
      if (Trigger.isDelete) {
          evts = Trigger.old;
      } else {
          evts = Trigger.new;
      }
  
      for (Event event: evts) {
          oppIds.add(event.WhatId);
      }
  
      List<RecordType> rtList = [ select Name from RecordType where SObjectType = 'Opportunity' and Name = 'van Wagenen' Limit 1];
      System.debug('RtList:'+rtList.Size());
      List<Opportunity> oppList = [select RecordTypeId,Next_Activity__c,Next_Activity_Date__c,(select Subject, ActivityDate from Events where isDeleted = false  order by ActivityDate asc) from Opportunity where Id IN :oppIds and recordTypeId = :rtList.get(0).Id];                  
      System.debug('Opp List:'+ oppList.size());
      System.debug('List Of Events Under Oppty:'+oppList[0].Events.Size());
      List<Opportunity> oppToUpdate = new List<Opportunity>();
  
      if (!oppList.isEmpty()) {
          for (Opportunity opp: oppList) {
          /* System.debug('Opp Events:'+ opp.Events.size());
           System.debug('Opp Events Subject:'+ opp.Events.get(0).Subject);
           System.debug('Opp Events Activity Date:'+ opp.Events.get(0).ActivityDate);*/
          
              if (!opp.Events.isEmpty() && opp.Events.get(0).Subject != null&&opp.Events.get(0).ActivityDate < opp.Next_Activity_Date__c) {
                      System.debug('Subject on Opportunity:'+opp.Next_Activity__c);
                      System.debug('Subject on Events:'+opp.Events.get(0).Subject);
                  if (opp.Next_Activity__c != opp.Events.get(0).Subject) {
                      opp.Next_Activity__c = opp.Events.get(0).Subject;
                     
                      System.debug('Subject on Opportunity:'+opp.Next_Activity__c);
                      System.debug('Subject on Events:'+opp.Events.get(0).Subject);
                   
                    
                  }
             
              }
               oppToUpdate.add(opp);
      }
     }
  
  
      if (!oppToUpdate.isEmpty()) {
          update oppToUpdate;
      }
  }
 
Hi All,
I am trying to write an agter update trigger to update date field in Bulk_Product__c object When date field in Bulk_Contract__c is Updated not on insert. Below my trigger is doing nothing please help me in finding my mistake. Thanks!

trigger UpdateExpirationDatesTrigger on Bulk_Contract__c (after update) {
 for (Bulk__Contract__c blkConUpd : trigger.new) {
        Bulk_Contract__c blkConOld = System.Trigger.oldMap.get(blkConUpd.Id);      
           List<Bulk_Product__c> blkProdList = [Select Id,New_Business_Expiration_Date__c FROM Bulk_Product__c WHERE Id = :blkConOld.Id];           
               for(Bulk_Product__c blk : blkProdList){
                 if(blk.Contract_Code__c == blkConUpd.Contract_Code__c&&blk.Company_Code__c ==blkConUpd.Company_Code__c){
                   blk.New_Business_Expiration_Date__c = blkConUpd.New_Business_Expiration_Date__c;
                   update ag;
                 
                   }
                     
               }
               
           }             
}
Hi All,

After Keeping if(!Test.isRunningtest()) to escape from the test class failure can we achive 100% code covarage on our trigger? I am having only 93% code covarage to my trigger. It has to be 100% to deploy this in prod. Any Suggestion how to gain 100% without removing 'if(!Test.isRunningtest())' Thanks!
Hi,
Can any one help me in modifying the following statment. I want a hyperlink under Team_Member__r.Name but i am not getting that. Please guide me. Thanks in advance!

mail.setPlainTextBody('This Message is to alert you that the Event Team Member named' + <a href ="https://cs8.salesforce.com/a0CL000000AnoUk" > eTMMap.get(eTM.Id).Team_Member__r.Name </a> + 'has been created/updated.');
Hi,
My Trigger is to update the Oppty 'Next_Activity__c' Field with the Task Subject based on First Open Activity(ActivityDate). Now the below trigger is updating the field when the task is inserted but not when the task was updated or deleted.

Ex : If I created a task1 with subject ='xyz' and  due date 20/1/2015
                          task2 with subject ='abc' and  due date 21/1/2015
then the Next_Activity__c = 'xyz' but when I am deleting task1 it has to update the Next_Activity__c with 'abc' but it is not doing so. Can any one help me in finding the problem.

trigger UpdateOppNextActivtyTrigger on Task (after insert,after update) {
  List<Id> idSet = new List<Id>();
   
  for (Task att: Trigger.new) {
     if ((att.WhatId + '').startsWith('006')) {
       idSet.add(att.WhatId);
      }
   }
   List<Opportunity> updateList = new List<Opportunity> (); 
   List<RecordType> rtList = [Select Id,Name from RecordType where SObjectType = 'Opportunity'and Name = 'van Wagenen' Limit 1];
   for (opportunity o: [Select RecordTypeId,Next_Activity__c, (select id,RecordType.Name, subject from Tasks where RecordType.Name='van Wagenen' order by ActivityDate asc limit 1) from Opportunity where id in : idSet ]){ 
       if (o.recordTypeId ==rtList[0].Id&&o.Next_Activity__c != o.tasks[0].subject&&o.tasks.size()>0) {         
           System.debug('Next Activity:'+o.Next_Activity__c);
           System.debug('Task Subject Before Update:'+o.tasks[0].subject);
           o.Next_Activity__c = o.tasks[0].subject;
           System.debug('Next Activity:'+o.Next_Activity__c);
           System.debug('Task Subject Before Update:'+o.tasks[0].subject);
           
           updateList.add(o);
           System.debug('Next Activity:'+o.Next_Activity__c);
           System.debug('Task Subject Before Update:'+o.tasks[0].subject);
       }
      
  }   
    update updateList;  
 }
Hi All,
 String zipcode1 = a.BillingPostalCode.substring(0,5);
        if(a.BillingPostalCode!=NULL&&countyMap.containsKey(zipcode1)) {
            a.County__c = countyMap.get(zipcode1).County__c;
   }
If I am using the above code it is working for zipcode1 > = 5  but throwing error System.StringException: Ending position out of bounds: for zipcode1<5  i.e; if Zipcode1 = 32809- it is updating the county as Orange
                        if Zipcode1 = 3280 it is throwing the above error on the account page.

Can any one help me how to avoide this error on account page.

Thanks,
Hi All,

Any one please advise me how to write a trigger that will send an email to alert when that record is created or updated or deleted.. Thanks!
Hi All,

I am trying to write a trigger that will get the subject of the Next Scheduled Activity and place it in a custom field under opportunity object called 'Next_Activity__c'. Can any one help me what was wrong in the below trigger.

trigger OpportunityActivityTrigger on Opportunity (after insert,after update) {
List <RecordType> rtList = [SELECT Id from RecordType where SobjectType='Opportunity' and Name='van_Wagenen' Limit 1];
list<Id> accIds = new list<Id>();           
 Map<Id,Task> TaskOppMap = new Map<Id,Task>();                   
      for(opportunity opp: trigger.new){
            if(opp.Id!=Null)
            accIds.add(opp.Id);
       }              
List<Task> taskList = [select Id, Subject, ActivityDate from Task where Id IN :accIds];                                               
        for(Task t: taskList){ 
                if(t.Id!=Null){
                TaskOppMap.put(t.Id, t);
                }
         }     
        for(opportunity o: trigger.new){
              
            if(o.recordTypeId==rtList[0].Id){
               Task ts = TaskOppMap.get(o.Id);
                o.Next_Activity__c=ts.Subject;                               
            }
         update o;            
        }
    
}


Thanks In advance!
Hi Guys,

I would like to create a field on the Oppty object that is called "Next Activity". In this field we need to populate the subject of the next scheduled activity related to the Oppty. I believe this requires an Apex trigger to accomplish this. Can any one help me in writting this trigger. Thanks in advance.

Regards,
 We Are having a custom field under case called Case_Age__c which is a formula field.I wanted to know if we could make the number of days in this a custom setting.  I want to be able to adjust this number quickly without having to go through development. What is this custom setting and how it will work? please help in finding this.

IF( IsClosed , ROUND(ClosedDate - CreatedDate, 0) , ROUND((NOW() - CreatedDate),0)) is my formula field and I am having a custom setting "Policy view" of type Hierarchy. Thanks!
Can Any one help me how to write the batch apex and schedule it to update the priority field to high when the case age touches 10 days.

I am having a custom field call Age__c which is a formula field that will calucalte the opend day to closed date difference and gets the age. Now I have to update the priority to high if the age touches 10 days by batch apex. Workflow and apex trigger won't work for this. Thanks in advance!
  My team would like to be able to add the some productsby using the Add Products  button through the UI. The button is placed on the account detail page. By clicking the button it should open a VF page to show the products that I want to add and a button called Add Products. So my Account Detail page button should call the Apex code to insert some products into the account. Can any one help me on this? Thanks
 Please help in writting apex trigger that will pre populate the task subject as the account name when hititng the new task button.

When I hit the New Task button, the Account name must be  in the Subject. We want it to be there when we hit new, not after we save.
Hi Friends,

Trying to create a visualforce page to enter field values of one object. While we try to hit save it has to check if all fields are entered if not it has to open a window/page to display the missed fields and ask user to enter values there itself and save from that page/window.

I picked one object and 10 fields if 2 fields are not entered in the first page and user tries to hit save it has to open a window/page to show those two fields and user has to enter those fields in the second page/window and hit save. Then the record should be saved.

I wrote normal code which will save record when all fields are provided. Can Any one help me on this code!.

Thanks & Regards, 
Hi All,

Can any one help me in writting the VF page and custom controller to fetch data from different objects based on input field and update the records.

Ex: If there is a custom object called assginment__c then by giving a assginment name as input value on the VF page controller has to pick that record and load the  fields on VF page to edit and update those record values in salesforce. 
Same way the same VF page has to upadte the values of 5 different objects which are not related to each other. So for this I need Cutom controller. 

Please help me in writing this page and controller. Thanks in advance!!!
Hi Friends,

Here is my issue. Please advise me or help me.
I am having a field called Id_Generator__c which is autonumber field under object named custom_account__c. Now I have to write a trigger that will take this autonumber field and encrypt that field and then it has to send that encrypted value to the document I am sending out for signature(esignature) and then after signature the trigger has to get the key and decrypt that and have to store that value. Please let me know if you guys have any idea.

Thanks,
 
Hi All,

I need help on creating Apex trigger Here is the scenario:
I am having two objects 1. Account  2. Account Branch with a master detail relation ship where Account is Master.
Fields:
Account Branch ->  Branch_Status__c.
Account           ->  Status, Client_Id__c and rollup summary field that will calculate number of Branchs under that account called         No_Of_Branches__c

Now My trigger has to update Account status as follows:
If Client_Id__c = 'X' and No_Of_Branches__c = 0 then Status = 'Closed Prospect'
If Client_Id__c contains SAP or PAS and No_of_Branches__c = 0 then status = Active
If Client_Id__c contains SAP or PAS and No_Of_Branches__c !=0 and Branch_Status_c!=Cancel then status = Active
(Here Branch_Status__c is a field of child object and trigger has to check status of Branches and have to determine cancel if all are on cancel state or not)
If Client_Id__c contains SAP or PAS and No_Of_Branches__c !=0 and Branch_Status__c==cancel then status = Inactive
(Here Branch_Status__c is a field of child object and trigger has to check status of Branches and have to determine cancel if all are on cancel state or not)

Can any one help to frame the trigger. The trigger has to be on the child object.

Thanks,

 
 
Hi Friends,

Here I am trying to insert tasks from account using apex trigger. This is working for individual edits but if I am trying to update the accounts using data laoder it is inserting tasks for those 5 accounts instead it is inserting task for one account. Here is my trigger please let me know the how to make this trigger to work for bulk updates using data loader.

trigger TaskInsertTriggerOnAccount on Account (after update) {
    List <RecordType> rtList = [SELECT Id from RecordType where SobjectType='Account' and Name = 'BB' Limit 1];
    List <task> taskToInsert = new List <task> ();
     Set<Id> accountIds = new Set<Id>();

    for(Account acc:Trigger.New){
    if(acc.Agent_Id__c!=NULL&&acc.Contracting_Completed_Date__c==date.Today()&&acc.Contracting_Complete__c==True&&acc.RecordTypeId==rtList[0].Id&&acc.status__c=='Active'){
     accountIds.add(acc.Id);
      }
    }
    
    Map<Id,Bulk_Product__c> bulkProdMap = new Map<Id,Bulk_Product__c>();
    List<Bulk_Product__c> bulkProdList = [Select Id,Bulk_Code__c,Bulk_acc__c from Bulk_Product__c Where Bulk_acc__c IN :accountIds and Bulk_Code__c = 'CCM' Limit 1];
    for(Bulk_Product__c bk:bulkProdList ){
     if(ag.Bulk_Code__c!=NULL){
      bulkProdMap.put(bk.Bulk_acc__c,bk);
      }
     }
    List<RecordType> rtList1=[Select Id from RecordType where SobjectType = 'Task' and Name = 'BB Tasks' Limit 1];  
   List<Account>  accList = [select id,ownerId,Name,Agent_Id__c,Status__c,RecordtypeId from Account Where Id IN:accountIds and RecordTypeId=:rtList[0].Id Limit 1]; 
     for(Account acc:accList){
     if((trigger.isUpdate)&&bulkProdMap.containsKey(acc.Id)){
     task t1 = new task ();
     t1.RecordTypeId = rtList1[0].Id;
     t1.ActivityDate = Date.today()+2;
     t1.Status = 'Not Started';
     t1.Description = 'New Contract----------------. Please make personal contact with the agent';
     t1.Subject = 'New Contracted Follow Up';
     t1.OwnerId = acc.ownerId;
     t1.WhatId = acc.Id;
     t1.Priority = 'High';
     taskToInsert.add(t1);
    
     }
     
  if(taskToInsert.Size()>0){
       insert taskToInsert;
       }
 
    }      
 }
Hi All,

Can any one guide me how to write a trigger on Account that has to create a task record (Only one record) and then send an email notification to the person who is in assgined to field. I wrote an after update trigger but it is creating multiple task records when ever i am editing account page for any reason.
Thanks!
Hi,
My Trigger is to update the Oppty 'Next_Activity__c' Field with the Task Subject based on First Open Activity(ActivityDate). Now the below trigger is updating the field when the task is inserted but not when the task was updated or deleted.

Ex : If I created a task1 with subject ='xyz' and  due date 20/1/2015
                          task2 with subject ='abc' and  due date 21/1/2015
then the Next_Activity__c = 'xyz' but when I am deleting task1 it has to update the Next_Activity__c with 'abc' but it is not doing so. Can any one help me in finding the problem.

trigger UpdateOppNextActivtyTrigger on Task (after insert,after update) {
  List<Id> idSet = new List<Id>();
   
  for (Task att: Trigger.new) {
     if ((att.WhatId + '').startsWith('006')) {
       idSet.add(att.WhatId);
      }
   }
   List<Opportunity> updateList = new List<Opportunity> (); 
   List<RecordType> rtList = [Select Id,Name from RecordType where SObjectType = 'Opportunity'and Name = 'van Wagenen' Limit 1];
   for (opportunity o: [Select RecordTypeId,Next_Activity__c, (select id,RecordType.Name, subject from Tasks where RecordType.Name='van Wagenen' order by ActivityDate asc limit 1) from Opportunity where id in : idSet ]){ 
       if (o.recordTypeId ==rtList[0].Id&&o.Next_Activity__c != o.tasks[0].subject&&o.tasks.size()>0) {         
           System.debug('Next Activity:'+o.Next_Activity__c);
           System.debug('Task Subject Before Update:'+o.tasks[0].subject);
           o.Next_Activity__c = o.tasks[0].subject;
           System.debug('Next Activity:'+o.Next_Activity__c);
           System.debug('Task Subject Before Update:'+o.tasks[0].subject);
           
           updateList.add(o);
           System.debug('Next Activity:'+o.Next_Activity__c);
           System.debug('Task Subject Before Update:'+o.tasks[0].subject);
       }
      
  }   
    update updateList;  
 }
Hi All,
 String zipcode1 = a.BillingPostalCode.substring(0,5);
        if(a.BillingPostalCode!=NULL&&countyMap.containsKey(zipcode1)) {
            a.County__c = countyMap.get(zipcode1).County__c;
   }
If I am using the above code it is working for zipcode1 > = 5  but throwing error System.StringException: Ending position out of bounds: for zipcode1<5  i.e; if Zipcode1 = 32809- it is updating the county as Orange
                        if Zipcode1 = 3280 it is throwing the above error on the account page.

Can any one help me how to avoide this error on account page.

Thanks,
Hi All,

Any one please advise me how to write a trigger that will send an email to alert when that record is created or updated or deleted.. Thanks!
Hi All,

I am trying to write a trigger that will get the subject of the Next Scheduled Activity and place it in a custom field under opportunity object called 'Next_Activity__c'. Can any one help me what was wrong in the below trigger.

trigger OpportunityActivityTrigger on Opportunity (after insert,after update) {
List <RecordType> rtList = [SELECT Id from RecordType where SobjectType='Opportunity' and Name='van_Wagenen' Limit 1];
list<Id> accIds = new list<Id>();           
 Map<Id,Task> TaskOppMap = new Map<Id,Task>();                   
      for(opportunity opp: trigger.new){
            if(opp.Id!=Null)
            accIds.add(opp.Id);
       }              
List<Task> taskList = [select Id, Subject, ActivityDate from Task where Id IN :accIds];                                               
        for(Task t: taskList){ 
                if(t.Id!=Null){
                TaskOppMap.put(t.Id, t);
                }
         }     
        for(opportunity o: trigger.new){
              
            if(o.recordTypeId==rtList[0].Id){
               Task ts = TaskOppMap.get(o.Id);
                o.Next_Activity__c=ts.Subject;                               
            }
         update o;            
        }
    
}


Thanks In advance!
Hi Guys,

I would like to create a field on the Oppty object that is called "Next Activity". In this field we need to populate the subject of the next scheduled activity related to the Oppty. I believe this requires an Apex trigger to accomplish this. Can any one help me in writting this trigger. Thanks in advance.

Regards,