Custom Function to update "stage" in Potentials when an invoice is created

Custom Function to update "stage" in Potentials when an invoice is created

Hi there,

I am a newly fully paid enterprise CRM member and trying to get my head round the custom functions at the moment. Instead of making our staff change the "stage" in potentials I want to automate it.. so when an invoice is created it marks the potential as "Closed Won". This can't be done with workflows, but can anyone help with how to do this with custom functions?

Thanks in advance!

Andre