I'm using Apex 20.2
I am developing an application for Receipts (money received from clients) we collect money. Once a receipt is saved a Voucher Number gets generated and assigned to the saved Voucher.
Since I have multiple branch offices I want to generate numbering Branch wise since money is collected at different locations. I thought of 2 ways to get this done.
1) Create Branch wise Receipt Forms with multiple tables and have Numbering sequence set. Challenge with this is that i will have to create a new form every time a new branch office is opened.
2) Create a Single Receipt Form and auto generate Numbering sequence Branch wise.
Let's say I have 2 Locations ABC & XYZ which are 2 branch offices:
When the user from location ABC logs in and generates Receipts, Numbering to start from 1.
ABC-1, ABC-2, ABC-3 and it goes on.
Whereas when the user from Location XYZ logs in and generates Receipts, Numbering to start from 1.
XYZ1, XYZ2, XYZ3 and it goes on.
Any help would be highly appreciated
Vinish Kapoor
Approach one is not a good idea. 2nd approach is fine.
You just need to identify the user and then change the sequence object. Follow these steps.
Create two DB sequence objects. For example, seq_abc and seq_xyz.
In Apex, you can set the Default value type SQL query for the Receipt number field and add the following query in it:
You need to find how you will identify the user, which user belongs to which company. You can create a master table for it.
Similarly, you can handle this in the database trigger too.
Create a before insert trigger on your receipt table, and the trigger code should be as follows:
VARSHA
Thanks for the reply..
"Create two DB sequence objects. For example, seq_abc and seq_xyz."
U mean based on the Location count i have to create DB Sequence objects for every Location.
Vinish Kapoor
Yes. Two sequences for two branches, 5 for 5 branches.
VARSHA
Thank you Vinish..