How to let the table lend record only once?

Im new in programming. Im working on ms dynamics ax and i have a problem.

Im making simple movie rental.

3 simple tables: - movies, - customers, - transactions.

I want to know how to restrict to assign a movie to ONLY ONE customer.

Now i can make transacionts like, for example:

Mr. Jones → Deadpool(id: 1)

Mr. Brian → Deadpool(id: 1)

in the same time, and its bad. They shoudn’t be able to rent the same disc at the same time.

You can have the validation on Customer and movie(to check if the combination already exist in that table). Override the validateWrite() method on table to do this validation.

You can also build an unique index, but consider this option only if you are planned to have an index on those fields(considering the cost of adding the index)

Hi, Welcome to DUG. Please always tag your AX version and post in the right forum.

Moved to Developer forum, please post any development related questions in Developer forum.

i made it and its working, thanks u very much for your advise

If Kranthi’s reply answered your question, please don’t forget to mark it as the verified answer.

If you used a different solution, please share it with us. It may help other members of Dynamics User Group community.