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
Shalaka KokateShalaka Kokate 

auto-number

In SalesForce, we would like to add a field (or multiple) for all of our accounts that designates them to a certain route. The format of this field would look something like : RouteName-#, 
where # denotes the position of the account for that RouteName. For example, if there are 50 accounts in 5CHA route, the field (let's call this Route Position) for all those accounts will start off as 5CHA, but will all have a unique position from 5CHA-1 to 5CHA-50. 

What we are hoping to achieve is to this field automatically increase or reduce for all affected accounts when we add or remove accounts, respectively, from the same route. The overall route order will most likely not change. For example, we have decided a new account will be in Route Position 5CHA-23, after the current 5CHA-22 but before the current 5CHA-23. This will place the new account at 5CHA-23, while all the subsequent account starting 5CHA-23 to 5CHA-50 will be updated by a +1 in their position. Similar trend will apply for when we are removing an account with a -1 to their Route Position. 

With that said, there will be no duplicates in Route Position for any accounts. There might be cases where an account might have up to 3 route positions if they belong in 3 different routes.
Beer NutthawanBeer Nutthawan

Hi Shalaka 

This is a very good challenging for me. 
Let me ask you more question:
1.  If you already created Account 5CHA-1, 5CHA-2, 5CHA-3, 5CHA-4, then after 2 weeks you inactive(may be you remove) the Account 5CHA-2, then what would be an Account Number of a new one? 
2. What can be a scenario that you can remove the Accounts? Why would you remove them? 
3. If 5CHA is the Route Name which you want to use for naming of an Account Number, so how would you name the account with 3 routes assigned?  Would it be like "5CHA-4CHA-3CHA-1"? 
4. If "5CHA-50" Account is Route "5CHA", but 4 months later it has been moved to Route "7CHA", then would you like to change the Account Number to be "7CHA-50"? 

The Account Number should be usnique key. Once it's removed, with the same account number it should not be replaced by other Account becuase this Account can be attached to a Case or Opportunity, and it can create a massive information. 

Thanks

Leo Lopez 9Leo Lopez 9
Hi Beer, 

Here are the answer to your questions:

1. If you remove 5CHA -2 then the following numbers should move one position up. 5CHA-3 would then become 2... 4 would become 3 and so on. If instead or removing you add one then the following numbers should move one position down. 
2. The reason for the unique number is to assign a position in a route, we are a compost pick up service. We can remove or add members depending on new members subscribing or current members cancelling their accounts. 
3. Here's the reason for the name schema 5(day of the week) CH (area of service) A(route differentiator). So, Friday we have 5 routes. 5CHA, 5CHB, 5CHC, 5CHD and 5CHE. Monday we have different routes: 1ARA, 1WMA, 1WMB...
4. No, we would like it to follow the logic of your first question. So, depending on the position in which is assigned for the new route the other positions will move up or down. 
Beer NutthawanBeer Nutthawan
Hi Leo Lopez 9

I totally have a wrong understanding your requirement, so sorry. 
May I ask? Are you going to do like Sales Visit with a Route Assigning to Accounts or someting? 
Would this "Route Position" field be a field in Account? And it will be like this field will be maintain once you assign a Route when you do visit(I guessed from 5CHA, which 5 is day of week)? Do you have like an Object which triggers this action, let's say Object name "Route Assign", 
which you will mapp Accounts to a particular Route when you do a Sales Visit, and when you add a new record, then the "Route Position" in Account object will be changed? 

Please correct me if I am wrong.
Look forward to get a change to help you.

Regrads 
Beer
Leo Lopez 9Leo Lopez 9
Hi Beer, 

Let me give you some context: We are a bike powered compost pick up service. So we create routes to pick up the compost from our accounts. The route position would be a field in the account, indeed. It would be the same unless a new member gets added or removed before that account. We don't have an object that triggers the action, it would be more of a manual thing: whenever you add or remove a member from route 5CHA (5 = Friday) for example, the rest of the 'route position field' for all the other members in that route should be updated. 

Let me know if this helps or if you want to talk further about what we are doing and what we need. 

Best, 
Shalaka KokateShalaka Kokate
Hi Leo,

I would also request you to take a look at the below link where "Usman Aslam" has suggested some soultion on this request:-

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BORZ

Thanks & Regards, 
Shalaka Kokate 
Beer NutthawanBeer Nutthawan
Hi Leo

You can just modify a code with Shalaka's solution and then you can use it.

Regards