• Nalec7
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Is there an icon for salesforce that I can put in my dock?
  • August 21, 2009
  • Like
  • 0
I have a custom contact field called Days Since Last Activity - Today()- LastActivityDate. However, the new business requirement is to only calculate Days Since Last Outgoing Call Types. The activity picklist values are Outgoing Email, Outgoing Call, Outgoing -  Call Hit

In Summer '14, you can access activity dates in formulas however you can not access activity/task types. I also tried workflows, no luck.

My understanding now is this must be done with a apex trigger. It would evaluate the Call type field and update the Custom field if the criteria is met. Does anyone any simular code that can be used?

Thanks, Chris
  • September 04, 2014
  • Like
  • 0

I have an existing Opportunity trigger in place which is capturing the lead source of the oldest contact in an account. We now need to have this also listed on the Account detail page. I've created a custom field called Orignal Source which mirrors the custom field built on the opportunity. So I just need some help tweaking this code to be used with the account object. Any help would be greatly appreciated.

 

trigger orginalSourceUpdateTrigger on Opportunity (before insert) {
// Original Source requirement class variable
        final Map<String, String> opportunityIDToAccountIDMap = new Map<String, String>();
        Set<String> uniqueAccountIDSet = new Set<String>();
        final Map<String, Contact> accountIDToOldestContactMap = new Map<String, Contact>();
      //  Set<string> oldestContactSet = new Set<String>();
      //  Set<String> oldestContactAssociatedWithCampaignMeber = new Set<String>();

        
        for(Opportunity eachOpportunity :Trigger.new) {  
        
        if(!opportunityIDToAccountIDMap.containsKey(eachOpportunity.id))
        {
        opportunityIDToAccountIDMap.put(eachOpportunity.id, eachOpportunity.AccountId);
        uniqueAccountIDSet.add(eachOpportunity.AccountId);
        }
        
        
        }

        for(Contact con: [Select id, LeadSource, AccountId from Contact where AccountId IN: uniqueAccountIDSet ORDER BY CreatedDate ASC])
        {
            if(!accountIDToOldestContactMap.containsKey(con.AccountId))
            {
            accountIDToOldestContactMap.put(con.AccountId, con);
          //  oldestContactSet.add(con.id);
            }
        }

        
        
        
        // Original Source Update
            try{        
                for(Opportunity opp: Trigger.new)
                {                  
                     opp.Original_Source__c = accountIDToOldestContactMap.get(opportunityIDToAccountIDMap.get(opp.id)).LeadSource;
                }
            }
            
            catch(Exception e)
            {}

}
  • November 16, 2012
  • Like
  • 0

I have created custom picklist fields for field reps to select who was part of the opportunity. This information is sent to payroll for commissions. However sometimes changes happen after the fact. Looking to get a field update notification when this happens to verify.

 

 

And (ISCHANGED( Inside_Sales_Rep__c), ISPICKVAL (StageName, "Won"))

 Once this is solved, then onto the Email Messages :smileyhappy:

 

  • December 10, 2009
  • Like
  • 0
I have a custom contact field called Days Since Last Activity - Today()- LastActivityDate. However, the new business requirement is to only calculate Days Since Last Outgoing Call Types. The activity picklist values are Outgoing Email, Outgoing Call, Outgoing -  Call Hit

In Summer '14, you can access activity dates in formulas however you can not access activity/task types. I also tried workflows, no luck.

My understanding now is this must be done with a apex trigger. It would evaluate the Call type field and update the Custom field if the criteria is met. Does anyone any simular code that can be used?

Thanks, Chris
  • September 04, 2014
  • Like
  • 0

I have an existing Opportunity trigger in place which is capturing the lead source of the oldest contact in an account. We now need to have this also listed on the Account detail page. I've created a custom field called Orignal Source which mirrors the custom field built on the opportunity. So I just need some help tweaking this code to be used with the account object. Any help would be greatly appreciated.

 

trigger orginalSourceUpdateTrigger on Opportunity (before insert) {
// Original Source requirement class variable
        final Map<String, String> opportunityIDToAccountIDMap = new Map<String, String>();
        Set<String> uniqueAccountIDSet = new Set<String>();
        final Map<String, Contact> accountIDToOldestContactMap = new Map<String, Contact>();
      //  Set<string> oldestContactSet = new Set<String>();
      //  Set<String> oldestContactAssociatedWithCampaignMeber = new Set<String>();

        
        for(Opportunity eachOpportunity :Trigger.new) {  
        
        if(!opportunityIDToAccountIDMap.containsKey(eachOpportunity.id))
        {
        opportunityIDToAccountIDMap.put(eachOpportunity.id, eachOpportunity.AccountId);
        uniqueAccountIDSet.add(eachOpportunity.AccountId);
        }
        
        
        }

        for(Contact con: [Select id, LeadSource, AccountId from Contact where AccountId IN: uniqueAccountIDSet ORDER BY CreatedDate ASC])
        {
            if(!accountIDToOldestContactMap.containsKey(con.AccountId))
            {
            accountIDToOldestContactMap.put(con.AccountId, con);
          //  oldestContactSet.add(con.id);
            }
        }

        
        
        
        // Original Source Update
            try{        
                for(Opportunity opp: Trigger.new)
                {                  
                     opp.Original_Source__c = accountIDToOldestContactMap.get(opportunityIDToAccountIDMap.get(opp.id)).LeadSource;
                }
            }
            
            catch(Exception e)
            {}

}
  • November 16, 2012
  • Like
  • 0
Is there an icon for salesforce that I can put in my dock?
  • August 21, 2009
  • Like
  • 0

When Task Field Type “Outgoing Call” is selected, then validate that checkbox “Hit” or “Miss” is selected.

 

Dependencies between the 2 fields won't work. Thanks

  • May 28, 2009
  • Like
  • 0