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
suncity65suncity65 

How to create auto number scheme on Text Type in salesforce.

hi all,

 

we have a scenario where in we need to have same number but different versions of it  in one of our objects.

eg: PartNumber and version ( both are text type) i want to create a custom autonumber scheme for the partnumber.

 

if i use autonumber type available in force.com, i cannot create another part object with same part number but different version, want help on solving this issue, any suggestion would be really great.

AishAish

I think what you need here are at least 2 fields:

1. Part Name

2. Part Number

 

Both of which can be text fields. Or only #2 can be a number field. You can choose to have a 3rd field for an autonumbered but that's not going to affect the solution here.

 

Write Apex code which: calculates the total number of Part records with the same name as being created as in field #1. Then before insert, populate field #2 on the record being created with the total of Part records+1.