Salesforce Blogs

Abhinav Gupta Abhinav Gupta Abhinav Gupta Abhinav Gupta

Apex API String.format(); Exploring Good & Bad Parts!

I recently came across this useful and under-documented Apex String API, i.e. String formattedString = String.format(String template, List<String> arguments)

String.format(..) is again based on the Java MessageFormat class; its documentation says: Treat the current string as a pattern that should be used for substitution in the same manner as apex:outputText.

Read More
Abhinav Gupta Abhinav Gupta Abhinav Gupta Abhinav Gupta

Salesforce WSC added support for Session Timeout handling!

Retrying web service call failures/exceptions is important because not every exception means it’s the “end of the world." There is always some hope for some exceptions, like Session timeouts or Invalid session IDs. One can always renew the session (if credentials are available) and make those failing web service calls work again.

Read More
Abhinav Gupta Abhinav Gupta Abhinav Gupta Abhinav Gupta

Apex Implementing Singleton Design Pattern

Singleton is pretty popular and one of the most simple design patterns. On many occasions, we want an Apex class to have a single instance only. Fortunately, it's possible and pretty easy with Apex. There can be different strategies to implement singleton in Apex (inspired by my Java days learning). Before that, the following are the prerequisites to make a class Singleton.

Read More