• Malathan2
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

I did an update of some installed plugins in Eclipse (did not change version, just software update) and the autocomplete no longer works, always coming up blank.  Any idea on how to fix this?

 

Eclipse Version: 3.4.2

I have been going around with Salesforce for a while about an "Undocumented Feature".  They stand behind the viewpoint that thie issue in question is by design and not a bug.  I however feel it is otherwise.  Wanted to get other's views on this.

 

 


Issue is that if you send an email out, it generates an activity log (task).  This is what we want.Salesforce uses batch processing, so whether you insert 1 record or 100 records, the associated trigger should be called only once.Problem is, when sending out 100 emails it generates 100 activity logs, but each is created individually, thus the trigger is called 100 times.

If the Task trigger were to perform any action, such as reading from the database, you just hit your limit due to the email api not working in batch mode when creating activity logs!  If everything is Salesforce is setup to work in batches, why not the SendEmail function, which takes a list of email objects to send in batch?

 

 

Code to reproduce this is as follows (look at log file to see Task Trigger is being called for every email sent). 

 

 

trigger SalesforceEmailIssue_Task on Task (before insert) { System.debug('********** SalesforceEmailIssue_Task *****************'); } public class SalesforceEmailIssue { public static void GenerateEmails(List<Contact> listContacts){ System.debug('********** SalesforceEmailIssue *****************'); System.debug('# of contacts: ' + listContacts.size()); List<Messaging.SingleEmailMessage> listMessages = new List<Messaging.SingleEmailMessage>(); // Build list of messages for(Contact c : listContacts){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setSaveAsActivity (true); mail.setHtmlBody('Test'); mail.setSubject('Test'); mail.setTargetObjectId (c.Id); listMessages.add(mail); } // Send emails try{ Messaging.sendEmail(listMessages); } catch(Exception ex){ System.debug('Exception occured: ' + ex); System.Assert(false, ex); } } //######################################## // TEST //######################################## public static testMethod void test(){ integer numOfEmails = 10; string emailAddress = 'claytond@axiumae.com'; try{ System.debug('********* CREATE ACCOUNTS ******************'); List<Account> listAccounts = new List<Account>(); for(Integer i = 0; i < numOfEmails; i++) listAccounts.add(new Account(name='Test' + i, BillingState = 'OR', Type='Prospect')); insert listAccounts; System.debug('********* CREATE CONTACTS FOR EACH ACCOUNT ******************'); List<Contact> listContacts = new List<Contact>(); for(Account a : listAccounts){ //Contact c = AxTestRecords.createContact(a.Id, true); listContacts.add(new Contact( FirstName = 'John' , LastName = 'Doe' , AccountId = a.Id , MailingState = 'OR' , Contact_Role__c = 'Billing Contact' , Email = emailAddress) ); } insert listContacts; GenerateEmails(listContacts); } catch(Exception ex){ System.debug('Exception occured: ' + ex); System.assert(false, ex); } } }

 

In a workflow, I am triggering through apex trigger code that fires off emails.  Even though each email is triggered individually by each workflow (field update on record that in turn fires off apex trigger), salesforce is batching these together, thus the trigger is getting called with multiple updates at once.   No problem.  Code handles that.

 

What it is having issues with is when one of those emails fails due to a bounced email address.  In this case, it seems none of the emails got sent (at least no activities exist on any of the records).

 

Anyone have an idea how to force the other's to be sent and only fail on the actual invalid email record?

 

1.  Since salesforce is combining the field updates into a batch, fix must be batch aware.  So I can't call "SendEmail" once for each email since governor limit restricts at 10 and we have ~100 being sent.

2.  Instead of using Apex, call out to an external webservice and generate emails there?  I would prefer not to go this route (been forced to on few other issues), but it is an option.

3.  ?

 

 

Basic code (simplified for example) is as follows - From a trigger, identify the list of contacts to be emailed and call method passing list of contacts.

 

      public static void GenerateEmails(List<Contact> listContacts){

            System.debug('********** SalesforceEmailIssue *****************');

            System.debug('# of contacts:  ' + listContacts.size());

             List<Messaging.SingleEmailMessage> listMessages = new List<Messaging.SingleEmailMessage>();

            // Build list of messages

            for(Contact c : listContacts){

                  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

                   mail.setSaveAsActivity  (true);

                  mail.setHtmlBody('Test');

                  mail.setSubject('Test');

                  mail.setTargetObjectId  (c.Id);

                  

                  listMessages.add(mail);

            }           

              // Send emails

            try{

                  Messaging.sendEmail(listMessages);

            }

            catch(Exception ex){

                  System.debug('Exception occured: ' + ex);

                  System.Assert(false, ex);

            }

      }

 

Message Edited by Malathan2 on 11-16-2009 03:35 PM
Hi there.. I'm trying to download Files through the API

When I fetch the File info... the value of the [downloadUrl] is:
/services/data/v29.0/connect/files/069410000002wABAAY/content?versionNumber=1

Calling this endpoint in the API returns null or empty result.

Any idea what should be done here?
 

I have been going around with Salesforce for a while about an "Undocumented Feature".  They stand behind the viewpoint that thie issue in question is by design and not a bug.  I however feel it is otherwise.  Wanted to get other's views on this.

 

 


Issue is that if you send an email out, it generates an activity log (task).  This is what we want.Salesforce uses batch processing, so whether you insert 1 record or 100 records, the associated trigger should be called only once.Problem is, when sending out 100 emails it generates 100 activity logs, but each is created individually, thus the trigger is called 100 times.

If the Task trigger were to perform any action, such as reading from the database, you just hit your limit due to the email api not working in batch mode when creating activity logs!  If everything is Salesforce is setup to work in batches, why not the SendEmail function, which takes a list of email objects to send in batch?

 

 

Code to reproduce this is as follows (look at log file to see Task Trigger is being called for every email sent). 

 

 

trigger SalesforceEmailIssue_Task on Task (before insert) { System.debug('********** SalesforceEmailIssue_Task *****************'); } public class SalesforceEmailIssue { public static void GenerateEmails(List<Contact> listContacts){ System.debug('********** SalesforceEmailIssue *****************'); System.debug('# of contacts: ' + listContacts.size()); List<Messaging.SingleEmailMessage> listMessages = new List<Messaging.SingleEmailMessage>(); // Build list of messages for(Contact c : listContacts){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setSaveAsActivity (true); mail.setHtmlBody('Test'); mail.setSubject('Test'); mail.setTargetObjectId (c.Id); listMessages.add(mail); } // Send emails try{ Messaging.sendEmail(listMessages); } catch(Exception ex){ System.debug('Exception occured: ' + ex); System.Assert(false, ex); } } //######################################## // TEST //######################################## public static testMethod void test(){ integer numOfEmails = 10; string emailAddress = 'claytond@axiumae.com'; try{ System.debug('********* CREATE ACCOUNTS ******************'); List<Account> listAccounts = new List<Account>(); for(Integer i = 0; i < numOfEmails; i++) listAccounts.add(new Account(name='Test' + i, BillingState = 'OR', Type='Prospect')); insert listAccounts; System.debug('********* CREATE CONTACTS FOR EACH ACCOUNT ******************'); List<Contact> listContacts = new List<Contact>(); for(Account a : listAccounts){ //Contact c = AxTestRecords.createContact(a.Id, true); listContacts.add(new Contact( FirstName = 'John' , LastName = 'Doe' , AccountId = a.Id , MailingState = 'OR' , Contact_Role__c = 'Billing Contact' , Email = emailAddress) ); } insert listContacts; GenerateEmails(listContacts); } catch(Exception ex){ System.debug('Exception occured: ' + ex); System.assert(false, ex); } } }