Tag Archives: SFDC

toLabel() function in SOQL

  • toLabel() is used to convert the results of a field into user’s language.
  • toLabel() can convert the results into user’s language, if the translation workbench is enabled.
  • In all Salesforce edition we can use toLabel().
  • For picklist and Record type values we can use the toLabel() function in SOQL.

Here is an example:

SELECT Name, toLabel(Industry) FROM Account

Result:

download (1)

Not Like Operator in SOQL

Sometimes we need “NOT LIKE” operator in SOQL.
But SOQL will not allow someone to write simple query using “Not Like” operator such as:

SELECT Name From Account Where Name Not Like '%Test%';

So, here is the solution:

SELECT Name From Account Where Not Name Like '%Test%';

If you are using “GROUP By” clause with “Not Like” operator, here is an example:

SELECT Name From Account Where Not Name Like '%Test%' Group By Name;

Salesforce: Sorting Picklist value into alphabetical order

Standard Object:

Go to Setup – App Setup – Customize – Standard Object – Fields – Picklist or Multi-select Picklist Field

Custom Object:

Go to Setup – App Setup – Create – Object – Fields – Picklist or Multi-select Picklist Field

  • Click Reorder button on the Picklist Field under the Picklist Values Section.
  • There will be a checkbox – “Sort values alphabetically. Values will be displayed alphabetically everywhere.”
  • Check on it and then click Save.
  • And now you can find Picklist or Multi-select Picklist Field values are in alphabetical order.