Close won in Dynamics 365 and invoice when a contract is signed

By General Input

When a contract is fully signed, we close the matching deal as won in Dynamics 365, raise the invoice, and announce the win in Microsoft Teams.

Integrations

  • Docusign
  • Microsoft Dynamics 365
  • Microsoft Teams

Type

Agentic Task

Categories

  • Sales
  • Finance

Watch Docusign for envelopes that reach completed status, meaning every signer has finished signing. When one completes, close the loop between the signed contract and our Microsoft Dynamics 365 records, then announce the win in Microsoft Teams.

Start by reading the signed agreement. Use Docusign Get Envelope for the envelope status, subject and completion date, List Recipients for everyone who signed along with their names, emails, roles and the dates they signed, and Get Envelope Form Data to pull the values that were actually typed into the document's form fields. From that form data extract the customer or account name, the total contract value, and the billing contact if the document captures one. Treat the form field values as the source of truth for the contract amount rather than anything in the envelope subject line.

Then find the deal. Use Dynamics 365 Query Records against the opportunity table, filtering on the customer name from the envelope and restricting to open opportunities only, so deals that are already closed are never touched. Account names rarely match exactly, so compare sensibly across naming variants: legal suffixes such as Inc, Ltd, LLC or GmbH, ampersands versus the word and, punctuation differences, and trading names versus registered names. It is fine to query the account table first if that helps resolve the customer to the right account before looking at their opportunities.

This next part is the important safeguard. Only proceed if the envelope matches exactly one open opportunity. If it matches none, or if it matches more than one and you cannot be confident which is correct, then close nothing and create nothing, making no changes whatsoever in Dynamics 365. Instead post a Microsoft Teams Create Channel Message to the revenue channel saying a contract was signed, naming the customer, the contract value and the signers, listing any candidate opportunities you found with their names and estimated values, and asking someone to confirm which deal it belongs to. Apply the same caution if the contract value from the envelope looks clearly wrong against the opportunity's estimated value, for example different by an order of magnitude, since that usually means the wrong deal was matched or a value was mistyped. In that case stop and ask in Teams rather than closing the deal.

When there is exactly one confident match, do three things in Dynamics 365. Use Win Opportunity to close it as won, using the actual contract value from the envelope as the closing revenue rather than the original estimate. Use Create Invoice to raise an invoice for the agreed amount against that customer, using the billing contact from the signed document. Use Create Record to log a note against the opportunity for audit purposes, holding the Docusign envelope id, the full list of signers with their names, emails and signing dates, and the contract value taken from the form fields.

Finally, post a Microsoft Teams Create Channel Message to the revenue channel announcing the win. Include the customer, the contract value, who signed, and the date the contract was completed. Write it as a short, readable announcement that a sales leader would actually want to read, not a dump of raw fields.

A couple of edge cases to handle. If the matched opportunity is already closed as won, skip the writes so the same contract is never processed twice, and say so in the Teams message. If one of the Dynamics steps fails after the opportunity has already been closed as won, state that clearly in the Teams message so nobody assumes the invoice and the audit note were created.

Related prompts

Explore more prompts
Screen chartered vessels for AIS gaps and sanctions red flagsSee where your Docusign signing process actually stallsSend a batch of Docusign envelopes from a Google SheetSignature chase console for stalled Docusign envelopesCatch phishing domains impersonating your brand each morningSend Workable offer letters for signature automaticallyDaily SonarCloud quality gate status board in TeamsNudge Dynamics 365 deal owners about stale pipeline in SlackUpdate Dynamics 365 deals automatically after every Gong callFile contact sales form leads into Dynamics 365 without duplicates