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

Auto-generating a Product Number Based on a Predefined Range

I'm developing a custom app to manage product numbering.  I'm not using the Product functionality from core SFDC.  I have the need for different product number ranges based on different product lines.  For example: Product Line 1 = PN10000-PN19999, Product Line 2 = PN20000-PN29999, etc.


The custom app will create a record for every new product that we need.  The sole purpose is to generate the product number.  I plan on having a lookup field for Product Line that will help determine the range.  Then I need to be able to find the last product number that was created in that range and increment the number by "1".


What's the best way to do that?  Can formulas be used for this?



You'll have to write a trigger that does this.
Message Edited by Jakester on 06-18-2009 09:51 PM
I was hoping not to have to use Apex, but it seems that I will have to.  Does anyone have an idea how I should structure this (i.e. what the code should look like)?  Many thanks.
It's not for the feint of heart. In addition to the trigger, you're going to have to write a unit test. If you're not a programmer, you're going to need to hire one.