• OriPrice
  • NEWBIE
  • 5 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I wrote an update trigger (tried both before and after update) on Case that checks some conditions and sends an email to the Case contact if they are true.

PROBLEM:  In the system logs, I’m seeing “Single email queued for send (pending commit)” and the email isn't sending.

Answers to obvious questions: I'm not seeing any errors in the logs, the trigger is firing okay and the field update I am doing in the trigger is happening.

Does anyone know why the email is not sending?  Here's the code:


trigger CaseClosedEmail on Case (before update) {
   
    List<Contact> cons;
    List<EmailTemplate> et = [Select Id From EmailTemplate Where DeveloperName ='CustomerSupportClose'];
    Set<Id> conIds = new Set<Id>();
    Map<Id, String> conInfo = new Map<Id, String>();
   
    //Put contactId of each case in a set so we can query the contacts
    for(Case c : trigger.new){
        conIds.add(c.ContactId);
    }
   
    //Get all the contacts of closed cases
    cons = [Select Id, Email From Contact Where Id in :conIds];
   
    //Put those contact IDs and their emails in a map
    if(cons.size() > 0 ){
        for(Contact c : cons){
            conInfo.put(c.Id, c.Email);
        }
    }

    for(Case c: trigger.new){
        if(c.Status == 'Closed'
        && conInfo.containsKey(c.ContactId)
        && et.size() == 1
        && c.Con_Close_Email_Sent__c == false){

            // Create a new single email message object
            // that will send out a single email to the addresses in the To list.
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
           
            // Strings to hold the email addresses to which we are sending the email.
            String[] toAddresses = new String[] {conInfo.get(c.ContactId)};
           
            // Assign the addresses for the To and CC lists to the mail object.
            mail.setToAddresses(toAddresses);
           
            // Specify the address used when the recipients reply to the email.
            mail.setReplyTo('support@genomequest.com');
           
            // Specify the name used as the display name.
            mail.setSenderDisplayName('Genome Quest Support');
           
            // Specify the subject line for your email address.
            //mail.setSubject('Your case ' + c.Id + 'has been closed');
           
            // Don't append the salesforce.com email signature to the email.
            mail.setUseSignature(false);
           
            //The IDs to ensure that merge fields in the template contain the correct data.
            mail.setTargetObjectId(c.ContactId);
            mail.setWhatId(c.Id);
           
            // Specify the template content of the email.
            mail.setTemplateId(et[0].Id);
                           
            // Send the email you have created.
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
       
            c.Con_Close_Email_Sent__c = true;
           
        }
    }
   
}

 
Hi All,

I need to select all the fields ( like accountName, accountNumber etc ) of Account ( or any sobject ) through SOQL.

I constructed the select qurey as follows.

DescribeSObjectResult res = binding.describeSObject( "Account" );
Field[] fields = res.getFields();
String expr = "";
for( int i=0; i < fields.length-1; i++ )
{
expr += fields[i].getName() + ", ";
}
expr += fields[ fields.length - 1 ].getName();

String qry = "Select " + expr + " from Account";
QueryResult res = binding.query( qry );

While executing this, I am getting following exception.

Is there any easier way to achieve this!

Kindly help me solve this problem!

Regards,
Ganesh Kumar N.S.A

Exception in thread "main" java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.crimson.tree.ElementNode2
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:217)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at com.adventnet.authentication.interceptor.ClientPrincipalAssociator.invoke(ClientPrincipalAssociator.java:52)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy1.importFromSForce(Unknown Source)
at com.adventnet.examples.ImportUtilClient.main(ImportUtilClient.java:39)
Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.crimson.tree.ElementNode2
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1278)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1603)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1271)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)
... 10 more
Caused by: java.io.NotSerializableException: org.apache.crimson.tree.ElementNode2
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1224)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1050)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:367)
at java.util.Vector.writeObject(Vector.java:1017)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
  • April 23, 2004
  • Like
  • 0