Submit documents to Coupa

By default, afer you process a document in AP Essentials, the Coupa AP integration posts documents to Coupa in the draft state. However, there are two methods you can use to submit documents after being successfully posted in the draft state.

  • Target system settings — use this method to submit all processed documents to Coupa.

  • Custom XSLT — use this method if you need to submit documents to Coupa conditionally, based on field values or other criteria.

"Submit" refers to a specific document state in Coupa, not to be confused with the generic sense of sending or posting a document.

Submit documents to Coupa using target system settings

If you want to submit all documents to Coupa, after being successfully posted in the draft state, simply enable the Submit documents setting in the target system settings. If a document cannot be submitted for any reason, it remains in Coupa in the "On Hold" or "Pending Approval" state, depending on your settings in Coupa.

Submit documents to Coupa using custom XSLT

If you need more control over which documents you submit to Coupa, you can use custom XSLT to determine which documents are submitted. This is helpful, for example, if you only want to submit documents with certain field values. The key to utilizing this feature is a custom XML element called should-be-submitted. When you use custom XSLT to add the should-be-submitted element to the output XML, and set its value to true, the Coupa AP integration submits the document to Coupa after being successfully posted in the draft state.

Consider the following example XSLT that transforms the final document output that is sent to Coupa.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="xml" indent="yes"/>
  <!-- This parameter includes the original XML output from AP Essentials -->
  <xsl:param name="ApsXml"></xsl:param>
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="invoice-header">
    <xsl:copy>
    <xsl:apply-templates/>
    <!-- Check if the value of the supplier description field contains the text, RDY. -->
    <!-- If RDY is present, add the should-be-submitted element, and set it to true. -->
    <xsl:if test="contains($ApsXml/Batches/Batch/Documents/Document/Parties/Party[Type='supplier']/Description, 'RDY')">
      <should-be-submitted>true</should-be-submitted>
    </xsl:if>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

The XSLT above checks the value of the supplier description field. If the description contains "RDY" in its value, the should-be-submitted element is added to the output. This element tells the Coupa AP integration to submit the document to Coupa after the initial posting. The should-be-submitted element is ignored by Coupa. Depending on the state of your output, results can vary according to the table below.

Output state Result
The XML element (should-be-submitted) is found and is set to true. The integration submits the document to Coupa after it has been posted in the draft state. If a document cannot be submitted for any reason, it remains in Coupa in the "On Hold" or "Pending Approval" state, depending on your settings in Coupa.
The XML element (should-be-submitted) is found, but the value is not set to true. The integration posts the document to Coupa in the draft state.
The XML element (should-be-submitted) is not found. The integration posts the document to Coupa in the draft state.
The output XML is invalid or not readable. The integration posts the original output document, before the custom transformation was applied, to Coupa in the draft state.