• Viv Ralls
  • NEWBIE
  • 0 Points
  • Member since 2014
  • Sr. Manager
  • Fidelis Cybersecurity

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Has anyone tried to use the state and country picklists on a custom address field?  
Hello,  I'd like to have this trigger updated to count opportunity pushes into another quarter OR I might be able to use a pushcount that more than 3 months in the future.  Can anyone offer advice?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
trigger OppPusher on Opportunity (before update) {
Date dNewCloseDate;
Date dOldCloseDate;
Boolean bPushed=false;

for (Opportunity oIterator : Trigger.new) { //Bulk trigger handler so that you can mass update opportunities and this fires for all'
                                            // gets new values for updated rows
    dNewCloseDate = oIterator.CloseDate; // get the new closedate 
    dOldCloseDate = System.Trigger.oldMap.get(oIterator.Id).CloseDate; //get the old closedate for this opportunity
    if (dOldCloseDate<dNewCloseDate) { //if the new date is after the old one, look if the month numbers are different
        if (dOldCloseDate.month()<dNewCloseDate.month()) { // the month number is higher, it's been pushed out
            bPushed=true;
        }
        else {
            if (dOldCloseDate.year()<dNewCloseDate.year()) { // the month wasn't higher, but the year was, pushed!
                bPushed=true;
                }
            }
        
    }
    if (bPushed==true) { // let's go make them sorry
        if (oIterator.PushCount__c==null) {
            oIterator.PushCount__c=1;
        }
        else {
        oIterator.PushCount__c++;           
        }
    }
Just windering where I track my progress on trailhead.  I have many accounts and I want to keep my trailhaead progress on one so I can easily know what I have left to do
Has anyone tried to use the state and country picklists on a custom address field?