Reputation: 119
Suppose I add one field called Acc Code in Account. In this field, user can manually input 2 digits of alphabets. Example: user create Account with Name "Successful Company Pty Ltd" and user manually inputs the Acc Code with "SC". user create another Account with Name "Another Company Pty Ltd" and user inputs the Acc Code with "AC".
On Opportunity, I add one field called Opp Code. This field contains 5 digits, 2 digits alphabets of Acc Code from Potential Customer (Account that is referred by Opportunity as customer) and 3 digits are autonumbering. The autonumbering depends on the Potential Customer. That means, for Potential Customer "Succesful Company Pty Ltd" the Opp Code is SC001, if there is a new Opportunity for it again, the code is SC002. If the Opportunity is created for Potential Customer "Another Company Pty Ltd" then the beginning Opp Code is AC001.
I need suggestion on how to implement the automated numbering depends on Potential Customer. I imagined using Plug-in, but not sure on how to search the last Opp Code number (since the number depends on Acc Code). Would anyone mind helping or giving an example on how to do this?
Thank you :)
Upvotes: 1
Views: 1597
Reputation: 1089
Here's how I would do:
Steps 3 - 5 should be in plugin. Its important that they are executed as atomic operation and only one at the time. Use Mutex class to ensure that, since crm plugins are executed in multiple processes. (unless you have farm deployment. In that case mutex won't work.)
Upvotes: 0
Reputation: 1759
The plugin route does seem to be the best approach. I would begin by drawing out my process on a white board or piece of paper. You need to be very clear when what happens. Then you can start writing the plugin because you know what needs to happen where.
I am sure you have found plenty of resources of how to write Crm plugins. The toughest thing with developing for Crm is the toughest thing for any type of development, you have to decided how you going to do things. For example:
Once you have a very clear picture of what you want to do, I am sure there is a lot of help that the community can give you, when you run into specific problems.
Based on all of these questions, will be the answer, in how best to approach this problem. It might be that the customer expects this for very little, and that you have to come up with a solution that is perhaps not very robust, but quicker to develop than a full plugin.
Upvotes: 1
Reputation: 2521
Here's a pseudo code solution.
Good luck
Upvotes: 1