My setting of the concurrent execution of MF doesnt work ?

3
Background : MF to create order id is set as after create event in order object. The problem is sometimes my customers create new orders at the same time and get the duplicate order id. I'd like to fix this problem by disallowing MF to be executed concurrently. I set below concurrent execution setting in the MF to create order id as below. But MF can still run at the same time and doesn't call the second MF indicated as the error MF. I tested by call MF directly from action button but still got the same symptom. And I tested in the modeler version 2.4.1.1 and 2.5.0-rc1, both versions give me the same result. Disallow : True Error message : Test error message Error microflow : MF_Wait_and_call_MF_to_create_order_id Could anyone advise how to correctly set concurrent execution in MF or how shoule I solve the duplicate id problem.
asked
4 answers
2

I'm not sure why your "disable concurrent execution" solution isn't working (I think it should), but you could use other methods for generating unique order numbers:

If you add an AutoNumber attribute to your Order objects, it is guaranteed to be a unique number (I think it uses the same auto numbering mechanism of the underlying database that generates the database IDs). You can then use this number to generate a unique order number.

An other option would be to use Java actions, which enables many options to solve the issue (like using java.util.UUID.randomUUID() or something similar, or using a synchronized method for generating order numbers).

answered
1

You could check how many rows there are present in the database before you commit the action. So when you create your order you could call a microflow which checks how many rows are stored + 1. Before you commit you should call the microflow again to assure that the id is unique. I've used this several times and it worked.

answered
1

Many thanks for your suggestion. Correct me if I'm wrong, I think it doesn't matter whether the order id is incremented from the latest id or the number of all existing orders. If 2 MFs to create the id still run simultaneously, both MF sessions still get the same beginning id.

I've already added sub MF to recheck the duplicate id to recreate the new one after the first calculation ends if duplication occur, but the problem still exists.

answered
1

Just to provide more information, the reason I don't use autonumber because the id need to be reset at every beginning of the year. And in the near future, old transactions need to be archived and purged from the system. so the new id generation tends to rely on the correct selection of the latest id.

answered