Salesforce generates random identifiers for internal “Id” field. However if we are looking for business identifiers we are left with AutoNumber which generates the sequential numbers. If we are looking for a business identifier with some entropy to enhance the security of it, Salesforce leaves us to custom develop it.
A Blog entry talks about few options of Salesforce random number generation. To ensure the entropy Crypto class is preferred over Math.random (I assume this is analogs to Math.random and SecureRandom in Java). But crypto’s getRandomInteger class doesn’t generate consistent length random number which might be a problem.
Here is a simple Apex class which generates consistent length (10 digits) random identifiers.
public with sharing class RandomNumberGenerator {
public static String generateRandomNumber() {
String randomNumber = generate();
if (randomNumber.length() < 10) {
String randomNumber2 = generate();
randomNumber = randomNumber + randomNumber2.substring(0, 10 - randomNumber.length());
}
return randomNumber;
}
public static String generateIdentifier(String prefix) {
return prefix + '-' + generateRandomNumber();
}
private static String generate() {
return String.valueOf(Math.abs(Crypto.getRandomInteger()));
}
}
Sample identifiers generated using this class:
1180069336
2399158548
1189306484
1453886484
2110260656
1859434534
9810064217
3475893391
8950171981
8562056261
When you have to spend some time dealing with Keystores and certificates, every tool which would make your workflow easier, is of a great help. When I was in same situation, it was really tough as you had to deal with many cli commands and that’s when I had determined to write a friendly GUI application.
Soon after I started working on Eclipse and found out about the Eclipse RCP. I really liked the capability and ease it brought to Java UI application development. So there it started my adventure to learn Eclipse RCP and write a GUI app to manage the Keystores and (if possible) PKI objects (like X.509 Certificates, CSRs, CRLs etc).
Today I’m releasing that effort as Putani PKI Explorer. Downloads are available as Windows/Linux/Mac 32/64 binaries. Wiki with features and user guide is on the way. However GUI is easy to use and friendly so I believe you will not have to try hard to understand it and use it.
I dedicate this effort to my father (July is his Shraaddha month), mother and brother. You guys have given me all that you had and you are the reason whatever I’m today. Thank you.
Putani name means a “little one”, affectionate way to call small children. I chose this name for my first niece (Lahari), my son (Kashyap) and second niece (Ritu).
I have been working on Salesforce for a last few months. It is a great platform with so much of flexibility. One thing they got to do a lot of work is around developer tools.
One recurring thing I do whenever I deal with Salesforce is to explore the objects, understand their relationships. It is not that easy to understand the objects relationships in the “user friendly” web UI nor in the Force.com Explorer.
Even though Force.com Explorer has some features like querying for data, displaying the child relationships, I really not comfortable with UI layout or the feel of Air components (hey, I really tried to like it
).
Long story short, I thought there is some opportunity for a nice tool to explore some aspects of Salesforce.com and started on a tool based on the fantastic Eclipse platform (Never tried Netbeans RCP platform so cannot speak for that). With in few weeks of time, I have added enough features to the tool that I would like to release to wider audience. Check it out.
I dedicate this tool to Kashyap (today he is 14 months old).
Real Force Explorer 1.0.2
Got this message today while logging into Yahoo Mail. Hope this is not something similar to what happened with Sony PSN 

At times the problem with Java eco-system is its complexity due to availability plethora of choice of tools/frameworks. Getting a basic application with appropriate stack working is the big hurdle.
Same goes with the effort to get the Gwt-Spring-Hibernate stack working.
There have been lots of references about Gilead and Gwt-Sl libraries and how to use them to glue the stacks together but couldn’t find a complete deploy-able application. Hence this post.
Here is a complete deploy-able war file and its source. The example uses the following libraries.
- Smart Gwt
- Gwt
- Gwt-Sl
- Gilead
- Spring
- Hibernate
- Hsqldb
Download the war, deploy and test it. Explore the source to get the understanding of stack. Post a comment if you have any questions.
Recent Comments