Generate Invoice from Opportunity when Closing as Won

Sales process is one of the main OOTB business processes in Dynamics CRM. During the sales process Opportunities can be created from Leads (Potential Customers) and opportunities contain opportunity products. From opportunities, quotes can be created, orders can be created from quotes and then invoices can be created from orders.


In this post let’s see how to generate invoice from opportunity using code and overcome issues when getting the OpportunityId.

CRM SDK provides few Methods to Generate Quotes, Orders and Invoices programmatically from Opportunity at any event. Following table shows the Requests and their descriptions that we can use to generate Quotes, Orders and Invoices from Opportunity.

Message Description
GenerateQuoteFromOpportunityRequest Generates a quote from an opportunity.
GenerateSalesOrderFromOpportunityRequest Generates a sales order from an opportunity.
GenerateInvoiceFromOpportunityRequest Generates an invoice from an opportunity.

Invoice can be created when the Opportunity closes as won and Plugin Continue reading “Generate Invoice from Opportunity when Closing as Won”