• Nathan Prats
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Sales Analyst
  • Azalead Software


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
Hello, 

I am desperately trying to get the Contact Titles from Events.
I couldn't create an activity custom field to get the Who.Title value.
I couldn't write a query with Who.Title so i'm trying to filter a contact query.
However, the below doesn't work. What am I doing wrong ? 

SELECT Id, Title, (SELECT CreatedDate, WhatId , WhoId FROM Events WHERE CreatedDate = TODAY AND Meeting__c = TRUE)
FROM Contact
WHERE Id IN (SELECT WhoId FROM Event WHERE CreatedDate = TODAY AND Meeting__c = TRUE)

Any help is more than welcome, 

Nathan,
Hi, 

I'd like to sum the results of 2 queries. I'd use those results in order to double check some figures. 
I pasted the two queries herebelow, they have different timeframe.

SELECT Sum(Power_of_1__c)
FROM Task
WHERE CallType = 'Outbound'
AND Sucessful_call__c = TRUE
AND CreatedDate >= LAST_N_WEEKS: 4

SELECT Sum(Power_of_1__c)
FROM Task
WHERE CallType = 'Outbound'
AND Sucessful_call__c = TRUE
AND CreatedDate >= LAST_N_MONTHS: 4

Any help would be much appreciated. 

Nathan
Hello, 

I'm trying to get the Title of the contact in this query. 
I know that events can be related to Leads or Contacts. That's probably what is causing this issue. 

SELECT CreatedBy.Name,Account_Name__c,Who.Name,CreatedDate, Who.Title
FROM Event 
WHERE CreatedBy.Profile.Name = 'Account Executives' 
AND Meeting__c = TRUE 
AND CreatedDate = today

Your help is much appreciated. 

Nathan
Hello, how do I test add.Error ?

This is my trigger trigger 

trigger CannotDeleteMQL on Event (before delete){
  for (Event e : Trigger.old){
    if (e.MQL__c=='Yes'){
      e.addError('You can\'t delete a MQL');
    }
  }
}

I tried this test class but it doesn't work: 

@isTest
public with sharing class CannotDeleteMQLTest {

     @isTest
    public static void cannotDeleteMQLTest () {
        
        // Event creation 
        Event e = new Event(
            Subject ='Fake Event',
            MQL__c = 'Yes',
            StartDateTime = datetime.newInstance(2014, 9, 15, 12, 30, 0),
            EndDateTime = datetime.newInstance(2014, 9, 15, 13, 30, 0)
        );

        try
           {
               Delete e;
            }
           catch(Exception z) 
           {    
                System.Assert(z.getMessage().contains('You can\'t delete a MQL!'));
            }

    }
}