Auto reference population

Auto reference population

Hi community,

Please can someone help me with writing a fucntion?

I need the auto reference number to only populate once a deal has been marked WON.

Thanks in advance!