I want Salesforce to generate a number on the portal it needs to go from 0000 to 9999 and it needs to be generated once the customer choses a number. eg, if the last generated number was 0021 and the customer presses 3 the numbers generated will be 0022 0023 0024. Where in salesforce would i store the last generated number only without storing all the previous numbers ? Any idea on how to approach this problem ? any guidence or tips would be usefull thank you .
You can create a custom setting (or an object in this case your object will need only 1 record that will contain that number) and store that number there. Then once it is changed just update that number.
For example create a Hierarchy Custom Setting Number Setting and add a number field there called Largest Number. Then add a default Organization Level Value - your start value i.e. 0:
Number_settings__c setting = Number_Setting__c.getOrgDefaults(); Double largest = setting.Largest_Number__c; // Display value of the variable largest where you need to // Do some manipulations i.e. increment your number // Assign your largest number to a variable largest setting.Largest_Number__c = largest; update setting;
This way that custom setting will keep your largest number.