How to create custom function script for autonumber in Zoho CRM ?

How to create custom function script for autonumber in Zoho CRM ?

hello,

this is my used case:

When the DEAL is WON, I want to generate automatic number which will be saved in the custom field I created.  The custom Field Name is ProjNum.

I cannot use the Zoho autonumber field because I only want to have autonumber when the DEAL is WON. Autonumber should be activated only when Close Won.