function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Peter MacEwan 10Peter MacEwan 10 

Salesforce for Outlook and Trigger

We have set-up Salesforce for Outlook to create activity records of the email type on the contact standard object.

We have also written an Apex Trigger to create records on a separate custom object when new activities of the email type are created on the contact standard object.

Each of these actions work independently when tested but when we attempt to use them together we are receiving an error message (in the Outlook sidebar).  Salesforce for Outlook will not create the activities when the trigger is installed.

Any guidance in problem-solving this issue is greatly appreciated.
 
SonamSonam (Salesforce Developers) 
It could be that the Activity being created through Salesforce for Outlook doesn't meet the criteria for the trigger or  doesn't carry a field value which is required to be used in the trigger because of which the trigger is unable to  complete execution resulting in the error - would it be possible for you to share the error message?
Peter MacEwan 10Peter MacEwan 10
Thanks Sonam.

The error message reads: "We couldn't add this item. Please try adding this item again."  The error message appears in the Outlook sidebar 

User-added image

 
SonamSonam (Salesforce Developers) 
Okay, this looks similar to a case that I've come across...Did you happen to check any validation rules that you might have created on the activity object which are making fields required that are not being filled when getting copied by SFO?
Peter MacEwan 10Peter MacEwan 10
We do not have any validation rules on the activity object.
SonamSonam (Salesforce Developers) 
Could you please setup debug logs on your user Acocunt in Salesforce and check to see what are the things running in the background when an Activity is saved through SFO to Salesforce?

Setting debug logs:
https://help.salesforce.com/HTViewHelpDoc?id=code_viewing_log_details.htm&language=en_US
Kenny JacobsonKenny Jacobson

Wierd.  Why have all my comments been deleted?!?

Well, in case anyone wants to know what our solution was, the problem was I wasn't getting the emails properly from "Salesforce For Outlook".  This is because the way an email is formatted for an Activity/Task differently whether you're sending the email directly out of SFDC vs and email sent through Outlook.  All the development I was doing was using the "direct from SFDC" and it was working.  But the problem is, when the users tried "Salesforce For Outlook", I wasn't parsing out the emails properly.  So this line of code was resulting in a null:

List<Contact> individualList = [Select Id, Current_Coach__r.Id, Current_Financial_Services_Staff_Contact__r.Id   From Contact Where email = :AllEmails];

Which then in turn made this line blow up:
for(Contact individual : individualList){
     Communication__c com = new Communication__c();
     /* Other code */
     com.CurrentCoach__c = individual.Current_Coach__r.Id ;
     /* Mote code */
}