<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.setServerField.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.setServerField</api:function-name><api:suggest>xdmp.setserverfield</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>setserverfield</api:suggest><api:function-link mode="xquery" fullname="xdmp:set-server-field">/apidoc/8.0/xdmp:set-server-field.xml</api:function-link><api:function mode="javascript" name="setServerField" type="builtin" lib="xdmp" category="AppServerBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.setServerField"><api:summary>
  Sets the value of a named server field. A server field is created with
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:set-server-field</code> and stores a name/value
  pair in memory.  The server field is available on the App Server in which
  it is set on the host in which the App Server runs, via
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:get-server-field</code>; a server field that is set on one
  App Server is not available on other App Servers on that host or on the same
  App Server running on another host.
</api:summary><api:params><api:param name="name" type="xs:string"><api:param-description>
    The name of the server field.</api:param-description><api:param-name>name</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="value" type="item()*"><api:param-description>
    The value of the server field. 
    <span class="javascript" xmlns="http://www.w3.org/1999/xhtml">If you pass in a single value, 
  it is treated as a ValueIterator with that single item; therefore, if you 
  pass in an array, the array is treated as a single value (not as one value
  for each item in the array). If you mean to pass in  
  the values of each item in the array, then you can call 
  <a href="./xdmp.arrayValues">xdmp.arrayValues</a> on the array. </span>
  </api:param-description><api:param-name>value</api:param-name><api:param-type>ValueIterator</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml"><code>http://marklogic.com/xdmp/privileges/xdmp-set-server-field</code></p>
</api:privilege><api:usage>
    <p xmlns="http://www.w3.org/1999/xhtml">If you use a server field with the system Plugin Framework (by placing
    the <code>xdmp:set-server-field</code> code in a main module under
    the <code>Plugins</code> directory on a host), then the server field
    will be populated for each App Server on the host before the first request
    against each App Server is run. </p>
    <p xmlns="http://www.w3.org/1999/xhtml">If you set a server field to the empty sequence, it deletes
    the server field and it will not appear when you run
    <code>xdmp:get-server-field-names</code>.</p>
    <p xmlns="http://www.w3.org/1999/xhtml">If you set a session or server field to a value that comes from a
  database node (for example, from the value of a search or the 
  <code>fn:doc</code> function), then that session or server field expires
  after the request time limit (10 minutes by default). These fields expire 
  because they contain references to stands in the database, and as long as
  those references exist the stand cannot be reclaimed (merged).  To keep
  such a node in a session or server field, make a copy of the node
  before adding it to the session or server field instead of using the node 
  directly from the database.</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.setServerField("foo", "bar");
=&gt; "bar"
</pre></api:example></api:function></api:function-page>