Incrementing Unique ID

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
denisv
Posts: 253
Joined: Thu Jan 19, 2006 4:36 pm
Location: Ireland
Contact:

Incrementing Unique ID

Post by denisv »

I have an app that logs calls. I have set it up to take the next call number using the MAX function. I also use a process to create the call and view and have assigned that to the menu option to create a call.

The problem is that the ID is allocated when the save is done. I can modify the process to increment the number as soon as you start the call, but obviously if another user starts a call they too will get the same numbert if the first call is not saved.

Is there a way that I could have a business object that just stores the next number and when I start the create call process, it takes the number and increments it. Even if the call is not ultimately saved and the call id is 'lost' that would not be a problem.
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

To ensure a unique number you need to add a rule like the following to the object being created:

If Call IS NEW Then Call.Number = MAX Call.Number + 1

The call number will be assigned only once at the exact moment the object instance is created. The user who first clicks Create button on the form will have the next sequential number assigned to his Call, even if he started the process of filling the form later than some other user. The other user will have a greater number assigned to his Call when he clicks Create.

You can find more details on assigning unique numbers in the "How To" document.
Aware IM Support Team
denisv
Posts: 253
Joined: Thu Jan 19, 2006 4:36 pm
Location: Ireland
Contact:

Post by denisv »

Thanks.

This is the method I have already implemented and it works fine. The issue is that the number only gets assigned when create is hit (for obvious reasons).

In my case however, there is a lot of information to record in the record before hitting Create, some of it mandatory. The customer may need to give the call id before they finished entering data. This means I cannot wait until the instance is ceated and that is why I was wondering is it possible to get the next number the minute the form is opened. I know the instance has not been created so MAX Call.Number + 1 at the begining of the Create Call Process won't work as the same number could be taken by several users.

That is why I was wondeing if there was another BO just with the value, is it possible to take the number and increment it by one as the first step in my create call process ?
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

For reliability reasons it would be better to wait until the system accepts entered data before giving away identification numbers. This prevents situations where entered data cannot be the saved, for example because of broken connection etc.

A solution to this is to create the instance in the beginning of the process, rather than waiting for the user to click Create button, i.e. instead of a process step:

ENTER NEW Call ...

have a couple of steps:

CREATE Call ...
EDIT Call

This will (a) create an instance with auto-assigned unique number and (b) will allow the user to save the entered data in portions if desirable. The object should have an additional attribute to indicate the current state. For example, the default value for State can be 'New' and will be assigned when the object is created. Once the user has finished entering all the necessary details he can change the state to 'Submitted'. The 'Value must be provided' and other validation rules should be made conditional to the State attribute. For example, instead of marking an attribute as mandatory, you could add the following rule:

If Call.State='Submitted' AND Call.ClientName IS UNDEFINED
Then REPORT ERROR 'Client name must be provided'

This will allow creating the instance without the client name, but will prevent the user from moving the object to 'Submitted' state.

Alternatively, you can use a combination of the two approaches:

ENTER NEW Call ...
EDIT Call

where you would collect the required minimum information before issuing an identification number (the first step) and then continue on to enter other details (the second step) before changing the state and performing necessary validation.
Aware IM Support Team
Post Reply