Posts Tagged ‘salesforce apex’

WeDid:Salesforce Custom Clone Button

Challenges An insurance company requires the renewal customer policy yearly. The out-of-box clone button is not sufficient as the policy dollar value will need to be recalculated and certain date fields change during the cloning process. Also, it will not copy all the child records.   Solution: Custom clone button with Apex Extension Related Objects…

Read More

WeDid:Salesforce Auto Renewal Email Services

Challenges This company sells maintenance contract to their customers. Each contract has a maintenance due date. A couple of emails are required to be sent out before and after the maintenance due date, for example, 10 days before the due date and 5 days after the due date. The standard workflow function has limitation building…

Read More

WeDid: Handling of bulk invoicing in Salesforce

Challenges A recruiting company refers the candidate to their clients daily. Each successful referral, referral fees will be charged the organisation. There are many referral records with different status. This company needs a mechanism to generate an Opportunity on the fly based on all the un-billed referral within the certain time range. The Opportunity can…

Read More

Salesforce VF Page: Retrieve Field without SOQL

I was working on a Salesforce project which involves a lot of VisualForce page customisation. During the development, I encountered a very common error “SObject row was retrieved via SOQL without querying the requested field”, but it took me awhile to find out the root cause. I wrote a VisualForce with Standard Controller and an…

Read More

Salesforce Apex: Send Notification when Task Created From Apex

Sometimes, we would want to create a list of tasks and assign them to users automatically in Apex. And, the assignees should get a notification that a task has been assigned to them. However, in apex class, there is nothing call “Notify Assignee” checkbox like what you see in the Task Workflow Action as shown…

Read More

Salesforce Apex: saveAsActivity

We have developed an Apex Trigger which will send an email notification to users whenever a task is edited. Instead of specifying the email address with the “setToAddresses()” function to the Messaging.SingleEmailMessage object, we use the “setTargetObjectId()” function. This can help to overcome the daily email governor limit that we have in Salesforce.   Messaging.SingleEmailMessage mail…

Read More

Salesforce: System.LimitException: Too many SOQL queries: 101

This is a common error for those who write trigger. This is caused by Salesforce Execution Governors and Limits. Bad example:   for(Account acc : Trigger.new) { List<Contact> conList = [SELECT id FROM Contact WHERE AccountId =: acc.Id] ; }   If there are more than 100 accounts created/updated at the same time using data loader…

Read More

WeDid: Salesforce Automating Record Sharing Based On Dynamic User Field Value

Challenges Case sharing rules are set to private. The customer would like to share it with specific users based on a User Lookup field.   Solutions: Create a trigger that automatically adds the User into CaseShare (Manual Sharing Rules). The solution must also cover the following scenarios: When the User Lookup field is changed from…

Read More

Salesforce Apex: Data Formatting

We have a blog explaining how to format the data in Visualforce Page. However, sometimes, we prefer to do this in Apex class instead. This gives us more control over the formatted data, e.g, reuse the formatted data to concatenate with the other data. Below is the example of formatting in Apex class: Formatting DateTime…

Read More

Salesforce as a Subscription Billing System

Salesforce is not just a powerful CRM tool but it can be extended to meet your business requirement too. One example is to turn your Salesforce instance into a subscription billing system.   Being a subscription business model company, it is ideal to track customer information and all the subscription deals in one place. Most…

Read More