<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.transaction.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.transaction</api:function-name><api:suggest>xdmp.transaction</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>transaction</api:suggest><api:function-link mode="xquery" fullname="xdmp:transaction">/apidoc/8.0/xdmp:transaction.xml</api:function-link><api:function mode="javascript" name="transaction" type="builtin" lib="xdmp" category="TransactionBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.transaction"><api:summary>
  Returns the transaction ID for the current transaction, or transaction IDs for
  all transactions with the given name.
</api:summary><api:params><api:param name="txn-name" type="xs:string" optional="true"><api:param-description>
    An optional transaction name.</api:param-description><api:param-name>txn-name</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="host-id" type="xs:unsignedLong" optional="true"><api:param-description>
    An optional host ID, for retrieving the transaction ID of a named
    remote transaction. Default: The current host (<code xmlns="http://www.w3.org/1999/xhtml">xdmp:host()</code>).
  </api:param-description><api:param-name>host-id</api:param-name><api:param-type>String</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">
     When called with no parameters, this function returns the transaction
     ID of the current transaction on the local host. When called with a
     <em>txn-name</em>, the transaction ID for the named local or remote
     transaction(s) is returned.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
     Transaction names need not be unique. This function will return
     multiple transaction IDs if more than one transaction matches
     the parameters.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
     To retrieve the transaction ID of a named remote transaction, supply
     a <em>host-id</em>. If <em>host-id</em> is unknown or MarkLogic Server
     is not online on that host, an exception is raised.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
     If no matching transaction exists, an empty sequence is returned.
  </p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.transaction();
=&gt; The transaction ID for the current transaction on the local host.
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.transaction("myNamedTransaction");
=&gt; The transaction ID for "myNamedTransaction" on the local host.
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.transaction("myNamedTransaction",
       xdmp.host("some-host.marklogic.com"));
=&gt; The transaction ID for "myNamedTransaction" on the remote host
   some-host.marklogic.com.
</pre></api:example></api:function></api:function-page>