function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anto HotelbedsAnto Hotelbeds 

Global variable in salesforce

Hi,

 

I have a situation I need to solve.

 

I want to have an autoincrease number that will be increased with every new lead created in the system. This variable shouldnt be increased with every lead,just with the ones which record type is "Group".

 

I figured out a solution: to create a custom object that will contain this number. Then, everytime a new Group lead is created, it will fire a trigger that will access to this object take the number and increase it. But I think I might have some concurrency problems....It will be rare, but it might happen.

 

Do you know any other solution for this case?

 

Thanks a lot!

 

Antonio

Best Answer chosen by Admin (Salesforce Developers) 
vishal@forcevishal@force

Custom Settings are like Custom Objects. You can store Org Wide Data which can be directly accessed from here. More information on Custom Settings  here : http://help.salesforce.com/help/doc/en/cs_about.htm

 

Yes, in your trigger, just check for the recordType and if it matches the one you need, only then execute the logic of incrementing the custom setting value by 1. 

All Answers

vishal@forcevishal@force

I would prefer a custom-setting here. Increase it with every Lead insert. 

 

However, is it necessary to have the Lead Auto-Numbers in sequence? If yes, then on deletion of a Lead, you'll have to write some more logic which might be complicated.

 

If this is not needed, then I think you should be able to do it with a custom setting too.

Anto HotelbedsAnto Hotelbeds

Can I increase the number only when the recordtype of the lead is "Groups"? If the answer is yes, it would definitely be useful for us.

 

What is exactly a custom setting? Never used it and never heard...

 

Thanks,

 

Antonio

vishal@forcevishal@force

Custom Settings are like Custom Objects. You can store Org Wide Data which can be directly accessed from here. More information on Custom Settings  here : http://help.salesforce.com/help/doc/en/cs_about.htm

 

Yes, in your trigger, just check for the recordType and if it matches the one you need, only then execute the logic of incrementing the custom setting value by 1. 

This was selected as the best answer
Anto HotelbedsAnto Hotelbeds

Thank you very much for your help!