Send Email using Apex and save as Activity

// Create an email message objectMessaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();String emailAddress = (String) obj.get(‘Email’);// String[] toAddresses = new String[] {obj.Email};String[] toAddresses = new String[] {emailAddress};/*mail.setToAddresses(toAddresses);mail.setSubject(subject);mail.setHtmlBody(body);mail.setWhatId(c.Id);*/mail.setTemplateId(templateId);mail.setTargetObjectId(obj.Id);

Understand the error – System.QueryException: List has no rows for assignment to SObject

Description This issue you may encounter in apex class if you have query like this: The following query is not returning any number of records: Lead l = [SELECT Id FROM Lead WHERE Id = : recordId]; The error “List has no rows for assignment to SObject” occurs when query doesn’t return any rows. Possible Reason …

Understand the error – System.QueryException: List has no rows for assignment to SObject Read More »

Can we change the ParentId of EmailMessage Record in Salesforce

Requirement If email-to-case feature is enabled, sending email creates EmailMessage and creates or updates Case based on thread. Sometimes emails sent (from customers in a new thread) are linked to already an existing Case and you come up requirement to link the EmailMessage record with existing Case instead creating new one. Please note that EmailMessage …

Can we change the ParentId of EmailMessage Record in Salesforce Read More »

Query list of apps installed in Salesforce

Requirement We can get the list of items in the Force.com app menu or App Launcher from the ‘AppMenuItem’ sobject. So, purpose is to get the list of apps installed from appexchange or created in a salesforce organization. Solution There is a sobject ‘PackageLicense’ represents licenses for installed managed packages.