How to automatically add a reference number