Monday, November 18, 2013

SQL Restrict Number of Characters

I have used the 'left()' function to limit the results of a query in the past, but sometimes it does not work. The other function that can be used to limit the results of a query is substring, here is how it is used:

select Substring(notes,1,4000) as notes from history

Where the 1 is where you start and the 4000 is how many characters you want to pull in.

SUBSTRING ( expression ,start , length )

Tuesday, November 12, 2013

Override Button to Pre populate Fields

I found this blog post the other day and though it was very well written and very helpful!

http://raydehler.com/cloud/clod/salesforce-url-hacking-to-prepopulate-fields-on-a-standard-page-layout.html

More button code notes that are Task Button specific:

/00T/e?
who_id={!$User.Id}                                 // Set "Assigned to" to current user
&what_id={!ExpenseAccount__c.Id}   // "Related to" which object
&tsk1=Roger Wicki                                 // Override "Assigned to" with this name
&tsk2={!User.Name}                               // Related Contact's Name
&tsk3={!ExpenseAccount__c.Name}  // The Object's name
&tsk3_id=01ID0000000OiBz                // My custom object's ID
&tsk4={!(TODAY() + 7)}                          // Due Date
&tsk5=Print%20Expenses                     // Subject
// &save=1
// &save=x
&retURL=/{!ExpenseAccount__c.Id}
&cancelURL=/{!ExpenseAccount__c.Id}

For other objects you when using Google Chrome you can right click and "Inspect Element" to identify the field ID and use '&00Ni000000CKJg7' to preset a field value. This is most helpful for standard fields because you can get the same ID for custom fields by clicking on the field in the setup and pulling the ID from the URL.

Monday, October 28, 2013

Insert Merge Field Shortcut for Word (Conga Mail Merge)

Below are the shortcut keystrokes for entering a Mail Merge field into a word document.

ALT - I - F - M - M

From there you would just copy the Salesforce field name into the field name and click OK.

Tuesday, October 22, 2013

Link to local file in Salesforce

It seems there is no really easy way to link to a local file from Salesforce. After researching this topic in detail the blog post below provides the best solution to including this functionality in Salesforce. The biggest pain point in this solution for the user is that you can not click a button and be directed right to the document/folder. You have to copy the link stored in the formula field you create and copy that into a new browser window. The post takes you through the step by step process very well though.

http://salesforcetechie.wordpress.com/2013/07/19/linking-to-local-folders-in-salesforce-records/

Monday, October 21, 2013

Apex Trigger - Only Run at Point of Entry

You can put in a very simple condition that will prevent a trigger from running when bulk updates are made. This will only let the trigger run when one record is being edited at a time. This will exclude List View updates and data loader insert/updates:

if (Trigger.new.size() == 1) {

if (Trigger.old[0].isConverted == false){

}

}

Friday, October 18, 2013

Trigger Before and After Explanation

  • Before triggers can be used to update or validate record values before they are saved to the database.
  • After triggers can be used to access field values that are set by the database (such as a record's Id or lastUpdated field), and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers.htm

Wednesday, October 2, 2013

Lead Conversion Trigger

Below is the syntax for a lead convert trigger.

trigger test on Lead (before update) {
 for(Lead lead:System.Trigger.new) {
  if (Lead.IsConverted)
  //do somethign here with converted leads
 }
}

Below is a more built out example from Jeff Douglas

http://blog.jeffdouglas.com/2009/02/13/enhancing-the-lead-convert-process-in-salesforce/