• Robert Crook
  • 0 Points
  • Member since 2021

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2

New to Apex but I'm looking to ammend a previously built apex class in our org. This creates set tasks for a user upon 'close won' of an Opportunity. 

Class is below.

I'm just trying to find how to ammend the core tasks which are being generated when this is run? So I want to add a few and ammend a few. 

I just don't know where this 'task list' is being pulled from.

Any advice welcome.


public class OpportunityOnBoardingTasksHandler {

  private static List<Task> TasksToCreate;
  private static Map<Id,Building__c> RelatedBuildings;
  private static List<Client_On_boarding_Task__mdt> TasksSettings;

  public static void loadRelatedBuildingsAndTasksSettings(Map<Id,Opportunity> old_opportunities, Map<Id,Opportunity> new_opportunities){
    Set<Id> buildings = new Set<Id>();
    for (Id key: new_opportunities.keySet()){
      if (
                new_opportunities.get(key).RecordTypeId == RecordTypeUtility.getInstance().getIdByName(RecordTypeUtility.OPPORTUNITY_BUSINESS) &&
                (old_opportunities.get(key).IsClosed != new_opportunities.get(key).IsClosed) &&
    RelatedBuildings = new Map<Id,Building__c>([SELECT Id, Center_Manager__c FROM Building__c WHERE Id IN :buildings]);
    TasksSettings = [SELECT DeveloperName, MasterLabel, Due_In_Days__c FROM Client_On_boarding_Task__mdt];
    TasksToCreate = new List<Task>();

  private static Boolean isClosedWon(Opportunity new_opportunity){
    return new_opportunity.IsClosed && new_opportunity.IsWon && String.isNotBlank(new_opportunity.Building__c);

  public static void createRelatedTasks(Opportunity old_opportunity, Opportunity new_opportunity){
    if (
            new_opportunity.RecordTypeId == RecordTypeUtility.getInstance().getIdByName(RecordTypeUtility.OPPORTUNITY_BUSINESS) &&
            (old_opportunity.IsClosed != new_opportunity.IsClosed) &&
      Id owner = RelatedBuildings.get(new_opportunity.Building__c).Center_Manager__c;
      if (String.isNotBlank(owner)){
        for (Client_On_boarding_Task__mdt setting: TasksSettings){
          Task new_task = new Task(Subject = setting.MasterLabel, Priority = 'Normal', Status = 'Open',
                       WhatId = new_opportunity.Id, Main_Property__c = new_opportunity.Building__c,
                       OwnerId = owner);
          if ((setting.Due_In_Days__c != null) && (setting.Due_In_Days__c != 0)){
            new_task.ActivityDate = System.today().addDays(Integer.valueOf(setting.Due_In_Days__c));
          } else {
            new_task.ActivityDate = System.today();

  public static void insertNewTasks(){
    if (!TasksToCreate.isEmpty()){
      insert TasksToCreate;
I have created a field on the contact record titled Twitter User Name.  I am now trying to create a hyperlink formula field that will take the user name entered and add it to the Twitter URL and I can't get it to work.  It works great as a custom link but I want to be able to place the URL in the page layout and not in the custom link section.  Any suggestions?

I have tried both of these options

HYPERLINK("http://twitter.com/Contact.Twitter_User_Name__c", "Twitter Account" )

HYPERLINK("http://twitter.com/Twitter_User_Name__c", "Twitter Account" )