Auto generate a Reference number

Hi there!

I’m new to SuiteCRM and this community!

I’m working on having an autogenerated reference in the contacts module, I’ll explain.

I have a custom ID field for my contacts with autoincrement, and a custom field that tells me what course they purchased.

Now I want to generate a custom code for another custom field, e.g. “RPA21620O”, where RPA is the info in the course field, 21 is the last two digits of the current year, 620 is the ID in the custom contact ID field and a suffix letter.

Can you help me achieve this?

I know I have to use a logic hook but I don’t know how to do this.

Hi @sarole,

Welcome to the community.

There are two ways you can achieve that. One is by using a workflow that automatically fills the field on save.

And the other is to autofill the field from a before_save logic hook: https://docs.suitecrm.com/developer/logic-hooks/

On your function you’ll need to concatenate the text you want.

$bean ->your_custom_field= $bean->any_other_field."Any_Constant_TEXT";

Hi,
Welcome to the SuiteCRM Community!
Logic Hooks Guide: https://docs.suitecrm.com/developer/logic-hooks/#_logic_hooks_php
Or as described in your query like “RPA21620O”, where RPA is the info in the course field, 21 is the last two digits of the current year, 620 is the ID in the custom contact ID field, and a suffix letter.
Same extension already developed by Outright Store. If want to see more functionality of the autoincrement/ unique id generator please follow the link https://store.outrightcrm.com/product/suitecrm-unique-id-generator/