-
Recent Posts
Archives
Categories
Tags
- Adapter Pattern
- Administration
- Apex
- Apex Method of the Day
- Approvals
- Batch Apex
- Careers
- Chrome
- Controller
- Customer Portal
- Dreamforce
- Dynamic Binding
- Field Set
- FinancialForce
- FinancialForce.com
- Force.com Site
- Heroku
- Hierarchical Custom Setting
- Identity Provider
- Interface
- ISV
- JSON
- Locking
- Managed Package
- message-driven-architecture
- OAuth
- Orizuru
- Plugin
- Productivity
- Security
- SObject
- SObject Secret Life
- Triggers
- Visualforce
Top Posts & Pages
RSS
Tag Archives: Apex Method of the Day
Apex Method of the Day – JSON.serialize(Object)
Sometimes using JSON.serialize on a custom Apex type does not provide sufficient control over how the JSON is serialized. For example, serializing an Apex type will include null values for all fields that haven’t been set, when you might prefer … Continue reading
Apex Method of the Day – String.format(String value, List<String> args)
The above is an example of simple token replacement and is equivalent to: Why bother? Well, for more complex strings use of String.format can be easier to write and maintain than concatenation, but a great benefit comes from its combination … Continue reading
Apex Method of the Day – String.isEmpty(String myString)
Rather than: Force.com Apex Code Developer’s Guide – String Methods
Apex Method of the Day – String myString.split(String regExp)
We can split a String into parts using a token, which in this case is a space: However, the following example, using “.” as a token will fail: System.AssertException: Assertion Failed: Expected: 3, Actual: 0 This is because the token … Continue reading
Apex Method of the Day – String myString.repeat(numTimes)
public class TestUtility { static Integer s_num = 1; public static String getFakeId(Schema.SObjectType sot) { String result = String.valueOf(s_num++); return sot.getDescribe().getKeyPrefix() + ‘0’.repeat(12-result.length()) + result; } } Force.com Apex Code Developer’s Guide – String Methods
Apex Method of the Day – Method (and other) Declarations in Anonymous Blocks
An anonymous block is Apex code that does not get stored in the metadata, but that can be compiled and executed using… Developer Console, Force.com IDE [or] The executeAnonymousSOAP API call A method can be defined and called within an Anonymous Block: Decimal d1 … Continue reading
Apex Method of the Day – Database.Batchable
MyIterableBatch implements Database.Batchable<AnyTypeYouLike> Examples: IntegerIterableBatch.cls CustomTypeIterableBatch.cls Force.com Apex Code Developer’s Guide – Using Batch Apex Original Tweet
Apex Method of the Day – List Iterator
Example: Force.com Apex Code Developer’s Guide – List Methods Force.com Apex Code Developer’s Guide – Custom Iterators Original Tweet
Apex Method of the Day – JSON.deserialize(jsonString, List.class)
List<Foo> f = (List<Foo>) JSON.deserialize(jsonString, List<Foo>.class); Force.com Apex Code Developer’s Guide – JSON Methods Original Tweet
Apex Method of the Day – New Map from SObject List
List<SObject> lst; … Map<ID, SObject> mp = new Map<ID, SObject>(lst); Force.com Apex Code Developer’s Guide – Maps from SObject Arrays Original Tweet