Is there a way to mark invoice as sent upon creating it from custom function?

Is there a way to mark invoice as sent upon creating it from custom function?

Hi, I am using a custom function to create my invoice. Is there a way to automatically mark the invoice as sent in that custom function, or do I first need to create the invoice and then have a step afterwards to mark it as sent?