Recently we had a requirement to use auto numbers for lead records.
However, based on where the lead records are being created from, we wanted to specify a different prefix to it.
For leads created manually, the format should be prefixed “L” followed by “– “and then 10 digit sequence number.
And if created through API the prefix should be B.
To achieve this, we can define an auto-number field with the following format.
Next, we can have a bool field (default – false) in the lead table, to identify if it is being created from the API, which we can set while creating the lead record through API.
And a Pre Create Plugin on Lead to check the value of that field.
If it is set (true), that we can replace the Prefix from L to B in the auto-number field within the context.
In the Pre Create plugin, we get the next sequence in the auto-number field, so simply replacing/setting the value of the auto numbering field did the trick.
Lead created through Web Application –
Lead created through API –
Here uniqueness was more important than the next sequence of the lead record so this solution worked.
Also check –
Hope it helps..