• Mandarya
  • NEWBIE
  • 25 Points
  • Member since 2019

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Im trying to do a count in apex on Events that were marked as cancelled for opportunities that were generated from referrals I know how to build the counts but don't know how or if its possible to combine the two. This is what ive got so far. But im not sure if you can use the WhatId for what im needing.
 
Date THIS_MONTH = System.today().toStartOfMonth();
Date NEXT_MONTH = THIS_MONTH.addMonths(1).addDays(0);
String IsRef = '%'+ 'Referral' +'%';

    public Integer getRefOpps(){
    return [SELECT Count()
            FROM Opportunities
            WHERE Opp_Enquiry_Source__c LIKE IsRef AND CloseDate => THIS_MONTH && CloseDate < NEXT_MONTH AND Stage !=: 'Closed Won' OR Stage !=: 'Completed' 
            ];
     }

    public Integer getCanxRefTask(){
    return [SELECT Count()
            FROM Event
            WHERE AND X1st_Appointment_With_Director__c = TRUE AND ActivityDate >= THIS_MONTH AND ActivityDate < NEXT_MONTH Outcome__c =: 'Cancelled by Them'
            ];
     }

Thank you in advance.
 
Im trying to do a count in apex on Events that were marked as cancelled for opportunities that were generated from referrals I know how to build the counts but don't know how or if its possible to combine the two. This is what ive got so far. But im not sure if you can use the WhatId for what im needing.
 
Date THIS_MONTH = System.today().toStartOfMonth();
Date NEXT_MONTH = THIS_MONTH.addMonths(1).addDays(0);
String IsRef = '%'+ 'Referral' +'%';

    public Integer getRefOpps(){
    return [SELECT Count()
            FROM Opportunities
            WHERE Opp_Enquiry_Source__c LIKE IsRef AND CloseDate => THIS_MONTH && CloseDate < NEXT_MONTH AND Stage !=: 'Closed Won' OR Stage !=: 'Completed' 
            ];
     }

    public Integer getCanxRefTask(){
    return [SELECT Count()
            FROM Event
            WHERE AND X1st_Appointment_With_Director__c = TRUE AND ActivityDate >= THIS_MONTH AND ActivityDate < NEXT_MONTH Outcome__c =: 'Cancelled by Them'
            ];
     }

Thank you in advance.