+ Start a Discussion
LSKLSK 

Conditional Auto-Number code?

Need to create an auto-number field that only creates an auto-number if a contract is converted to Active - from Draft status.
Does anyone know what code would do this?
 
Thanks,
LSK
j_paqj_paq
LSKLSK
Thanks for writing. I've looked at the solution and tried to imitate the process using a S-Control object - but am not versed enough to write the validation code so that if the Contract Status = Activated then the Contract Number would be generated. I know there must be an easy waya to code this but I'm really struggling for the solution. Can you provide further insight?
 
Thanks,
LK
j_paqj_paq

You're welcome.  I'm not sure how much more insight I can provide, so here's how I use it. 

I ported their code (many thanks to them for their work!) to use on a custom object.  Some records need to be filed, some just need to exist for information and tracking and are never filed.  For the ones that are filed, the user has to push a button to assign the file number. The code checks the "file number" object and then increments and updates the field after a confirmation alert. This was probably not the cleanest way, and it doesn't make use of all the API features, but I too am not versed enough to code this in Apex.  It works fine for us since the group that uses it wants full control over when and if a number is assigned.

I'm thinking you could probably change the S-Control behavior to evaluate the Contract Status when the page saves instead of a button?

LSKLSK
I think the idea is what I'm looking for. I'll give it a try. It sounds easy enough. Will let you know how it goes!
 
Many thanks!
Linda