Generating Random Numbers in Salesforce

By | May 31, 2016

While working on our integration product we had this requirement of assigning a random value to one of the entity properties. This is a very common requirement and this can be easily achieved using the methods available in the system defined class name “Math”. Not just this you can even specify the length for the random number you would like to generate. Here is small snippet that demonstrate this functionality

Get Random Code

Here is the output of number it generated:

Random Code Output

Math class contains methods  for mathematical operations and you can explore the other utility functionality it provides here,  https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_math.htm

About Us
Greytrix as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce integration with Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.

Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information, please contact us at salesforce@greytrix.com. We will be glad to assist you.