You need to sign in to do that
Don't have an account?
JoshTonks
How do I use WhatId on Events to only look for events
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.
Thank you in advance.
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.
Build your query on top of below one :--
select Count() from event where X1st_Appointment_With_Director__c = TRUE AND what.Opp_Enquiry_Source__c LIKE IsRef
All Answers
Build your query on top of below one :--
select Count() from event where X1st_Appointment_With_Director__c = TRUE AND what.Opp_Enquiry_Source__c LIKE IsRef
Im getting the following message
No such column 'Opp_Enquiry_Source__c' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. Is this because of how the What field works on events. That field defiantly exists ive used it previously but its not working