• David Wright 97
  • NEWBIE
  • 20 Points
  • Member since 2018

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

I am interested to know if it possible to autopopulate a picklist field, with the value of another picklist field, upon Opportunity ‘StageName’ being moved to a certain value.

This would need to be carried out pre-save of the record, i.e. as soon as the Stage is moved on screen.

Many thanks
David
Does anybody know if it is possible to search for a trigger by it's name, either within SFDC or by using Workbench? 

Thanks
Hi everyone,

I currently have no coding knowledge so hoping somebidy is able to provide some assistance.  

I have the below trigger which populates a custom actvity field, 'Task Created and Completed By Current AE', when a completed task was created by the current Account Owner.

It is currently firing on the 'WhatId' field being related to an Account.

Is somebody able to update the language to also include Contacts? So if a completed task is created against a contact, and the Account Owner of the related contact matches the task creator, then the 'Task Created and Completed By Current AE' is also populated?

Greatly appreciate any help that can be provided. 

Best regards
David      

/**This trigger updates the "Task Created and Completed by Current AE" checkbox when the Task Created by the Account Owner moves to "Completed" status**/

trigger updateTaskCompletedByAECheckBox on Task(before update,before insert)
{
  List<Id> acclist = new List<Id>();
  Set<Id> taskSet = new Set<Id>();
  for (Task tsk: Trigger.new)
  {
    //Check if the Task Status is Completed
    if((tsk.Status == 'Completed') && tsk.WhatId != null)
    {
      String s = (String) tsk.WhatId;
      if(s.substring(0,3) == '001')
      {
        accList.add(tsk.whatId);
        taskSet.add(tsk.Id); //Set that contains the Completed Tasks linked to accounts
      }  
    }
  
  }
  
  Map<Id,Account> accMap = new Map<Id,Account>([Select id,Name,OwnerId from Account where Id in:accList]);
  
  for (Task tsk: Trigger.new)
  {
    Account acc= accmap.get(tsk.WhatId);
    if(acc!=null)
    {
    Id AcctOwnerId = accmap.get(tsk.WhatId).ownerid;
    
      if(Trigger.isInsert)
      {
        if((taskSet.contains(tsk.Id)) && UserInfo.getUserId() == AcctOwnerId)  //If the Task was Created by the Account Owner and its is Completed, then check the checkbox
          tsk.Task_Created_and_Completed_By_Curent_AE__c = true;
      } 
      
      else if(Trigger.isUpdate)
      {
        if((taskSet.contains(tsk.Id)) && tsk.CreatedById == AcctOwnerId)  //If the Task was Created by the Account Owner and its is Completed, then check the checkbox
          tsk.Task_Created_and_Completed_By_Curent_AE__c = true;
      } 
         
    } 
 
  }

}
Hi,

I am interested to know if it possible to autopopulate a picklist field, with the value of another picklist field, upon Opportunity ‘StageName’ being moved to a certain value.

This would need to be carried out pre-save of the record, i.e. as soon as the Stage is moved on screen.

Many thanks
David
Does anybody know if it is possible to search for a trigger by it's name, either within SFDC or by using Workbench? 

Thanks
Hi everyone,

I currently have no coding knowledge so hoping somebidy is able to provide some assistance.  

I have the below trigger which populates a custom actvity field, 'Task Created and Completed By Current AE', when a completed task was created by the current Account Owner.

It is currently firing on the 'WhatId' field being related to an Account.

Is somebody able to update the language to also include Contacts? So if a completed task is created against a contact, and the Account Owner of the related contact matches the task creator, then the 'Task Created and Completed By Current AE' is also populated?

Greatly appreciate any help that can be provided. 

Best regards
David      

/**This trigger updates the "Task Created and Completed by Current AE" checkbox when the Task Created by the Account Owner moves to "Completed" status**/

trigger updateTaskCompletedByAECheckBox on Task(before update,before insert)
{
  List<Id> acclist = new List<Id>();
  Set<Id> taskSet = new Set<Id>();
  for (Task tsk: Trigger.new)
  {
    //Check if the Task Status is Completed
    if((tsk.Status == 'Completed') && tsk.WhatId != null)
    {
      String s = (String) tsk.WhatId;
      if(s.substring(0,3) == '001')
      {
        accList.add(tsk.whatId);
        taskSet.add(tsk.Id); //Set that contains the Completed Tasks linked to accounts
      }  
    }
  
  }
  
  Map<Id,Account> accMap = new Map<Id,Account>([Select id,Name,OwnerId from Account where Id in:accList]);
  
  for (Task tsk: Trigger.new)
  {
    Account acc= accmap.get(tsk.WhatId);
    if(acc!=null)
    {
    Id AcctOwnerId = accmap.get(tsk.WhatId).ownerid;
    
      if(Trigger.isInsert)
      {
        if((taskSet.contains(tsk.Id)) && UserInfo.getUserId() == AcctOwnerId)  //If the Task was Created by the Account Owner and its is Completed, then check the checkbox
          tsk.Task_Created_and_Completed_By_Curent_AE__c = true;
      } 
      
      else if(Trigger.isUpdate)
      {
        if((taskSet.contains(tsk.Id)) && tsk.CreatedById == AcctOwnerId)  //If the Task was Created by the Account Owner and its is Completed, then check the checkbox
          tsk.Task_Created_and_Completed_By_Curent_AE__c = true;
      } 
         
    } 
 
  }

}