<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>John James Andersen</title>
	<atom:link href="http://www.john-james-andersen.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.john-james-andersen.com</link>
	<description>The Personal &#38; Professional Website</description>
	<lastBuildDate>Fri, 20 Aug 2010 20:26:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Remotely accessing data from another Service-now instance</title>
		<link>http://www.john-james-andersen.com/blog/service-now/remotely-accessing-data-from-another-service-now-instance.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/remotely-accessing-data-from-another-service-now-instance.html#comments</comments>
		<pubDate>Fri, 20 Aug 2010 20:26:17 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=496</guid>
		<description><![CDATA[I am currently working on a phased project in an Service-now.com instance that will temporarily integrate with an older service-now.com instance until all phases are complete within the new instance. As I considered my options, I realized that I could use SOAP Web Services to synchronize this data. However, upon careful reading I found a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.john-james-andersen.com/wp-content/uploads/remote-300x225.jpg" alt="" title="remote" width="300" height="225" class="aligncenter size-medium wp-image-497" /></p>
<p>I am currently working on a phased project in an <a href="http://www.service-now.com">Service-now.com</a> instance that will temporarily integrate with an older service-now.com instance until all phases are complete within the new instance.</p>
<p>As I considered my options, I realized that I could use SOAP Web Services to synchronize this data.  However, upon careful reading I found a semi-undocumented way to remotely send and retrieve data from another Service-now.com instance in a way very similar to &#8220;GlideRecord&#8221;.</p>
<p>This Java class is named: RemoteGlideRecord.</p>
<p>Here is a nifty way of querying all of the incidents in the &#8220;Demo&#8221; instance at Service-now.com using the RemoteGlideRecord class:</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// Set up the remote connection info</span><br />
<span style="color: #003366; font-weight: bold;">var</span> RemoteGlideRecord <span style="color: #339933;">=</span> Packages.<span style="color: #660066;">com</span>.<span style="color: #660066;">glide</span>.<span style="color: #660066;">communications</span>.<span style="color: #660066;">RemoteGlideRecord</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> remote_instance <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;https://demo.service-now.com&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> table_name <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;incident&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RemoteGlideRecord<span style="color: #009900;">&#40;</span>remote_instance<span style="color: #339933;">,</span> table_name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
<br />
<span style="color: #006600; font-style: italic;">// Set up the authentication</span><br />
<span style="color: #003366; font-weight: bold;">var</span> username <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;admin&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> password <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;admin&quot;</span><span style="color: #339933;">;</span><br />
r.<span style="color: #660066;">setBasicAuth</span><span style="color: #009900;">&#40;</span>username<span style="color: #339933;">,</span> password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// Perform the query</span><br />
r.<span style="color: #660066;">addQuery</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;incident_state&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
r.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span> r.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; gs.<span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Short Description: &quot;</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;short_description&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; (P): &quot;</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;priority&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/remotely-accessing-data-from-another-service-now-instance.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Null Responses with Web Service clients</title>
		<link>http://www.john-james-andersen.com/blog/service-now/493.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/493.html#comments</comments>
		<pubDate>Tue, 17 Aug 2010 16:35:32 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/blog/service-now/493.html</guid>
		<description><![CDATA[A lot of people have been running into a problem where they are using .NET or Java Axis libraries to connect to SOAP Web Services in their Service-now.com instance. Many people neglect to turn off the elementDefaultForm setting in Service-now. The creates problems in some client libraries. You know you probably are suffering from this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.john-james-andersen.com/wp-content/uploads/nullimage.gif"><img src="http://www.john-james-andersen.com/wp-content/uploads/nullimage.gif" alt="" title="nullimage" width="193" height="186" class="aligncenter size-full wp-image-491" /></a></p>
<p>A lot of people have been running into a problem where they are using .NET or Java Axis libraries to connect to SOAP Web Services in their Service-now.com instance.  Many people neglect to turn off the elementDefaultForm setting in Service-now.  The creates problems in some client libraries.  You know you probably are suffering from this problem when you send a SOAP request to your Service-now web service and find that you are only getting back a blank response.  </p>
<p>I have created a short little video clip that helps you see what you need to do to fix this issue and get your .NET and Java clients speaking to Service-now.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/AQFqGPXzXo8?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/AQFqGPXzXo8?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/493.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flush that Cache</title>
		<link>http://www.john-james-andersen.com/blog/service-now/flush-that-cache.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/flush-that-cache.html#comments</comments>
		<pubDate>Tue, 27 Jul 2010 22:20:13 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=478</guid>
		<description><![CDATA[I was recently helping a customer with a problem that they were seeing when they had installed a plug-in one one of their Service-now.com instances. I found that they had duplicate records in the &#8220;Classes &#8211; Table&#8221; list. One record had the correct Super Class and the other one had no Super Class. This was [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.john-james-andersen.com/wp-content/uploads/flushit.jpg" alt="" title="Flush the Cache" width="335" height="333" class="aligncenter size-full wp-image-479" /><br />
I was recently helping a customer with a problem that they were seeing when they had installed a plug-in one one of their Service-now.com instances.  I found that they had duplicate records in the &#8220;Classes &#8211; Table&#8221; list.  One record had the correct Super Class and the other one had no Super Class.  This was causing their problem.</p>
<p>I deleted the errant record, but when I went to examine the table schema in the Table Viewer, I found that the Super Class fields were still not showing up.</p>
<p>After scratching my head for several minutes, I finally went to the <a href="http://www.servicenowguru.com">Service Now Guru</a> himself and asked him what he thought needed to be done.</p>
<p>He wondered if the information we were seeing in the database schema were simply a cache of old data before the correction that I had made.  He proceeded to show me a quick and easy way to flush the database cache.  All you have to do is add the following to your base Service-now.com url:  &#8220;cache.do&#8221;.  This url will call a script that flushes your database cache.</p>
<p>Sure enough, as soon as I flushed the cache with this nifty trick, I found myself looking at the corrected schema.</p>
<p>Please Note: Flushing the cache can cause system performance degradation until the cache is fully repopulated again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/flush-that-cache.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filters &amp; Groups in Service-now URL&#8217;s</title>
		<link>http://www.john-james-andersen.com/blog/service-now/filters-groups-in-service-now-urls.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/filters-groups-in-service-now-urls.html#comments</comments>
		<pubDate>Thu, 15 Jul 2010 18:43:45 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=472</guid>
		<description><![CDATA[I have known for quite some time that you can export records from any table from a URL (assuming you have rights to access that table). Several months ago, I discovered that you could not only get list information, but you could also filter it. Today, I found out that beyond filtering, you have the [...]]]></description>
			<content:encoded><![CDATA[<p>I have known for quite some time that you can export records from any table from a URL  (assuming you have rights to access that table).  Several months ago, I discovered that you could not only get list information, but you could also filter it.  Today, I found out that beyond filtering, you have the power to group the list results from the filter.</p>
<p>Let me explain how to use filters and groups with Service-now.com list URL&#8217;s.</p>
<p>According to the Service-now wiki on the &#8220;<a href="http://wiki.service-now.com/index.php?title=Exporting_Data">Exporting Data</a>&#8221; page, you can export a number of records from a service-now table by appending a processor at the end of the URL.  For example, if I want to export the records in the incident table as XML, I would format my URL like so:</p>
<blockquote><p>http://myinstance.service-now.com/incident.do?XML</p></blockquote>
<p>I could also export it into a CSV file in the following (and similar) way:</p>
<blockquote><p>http://myinstance.service-now.com/incident.do?CSV</p></blockquote>
<p>Now, what if I wanted to filter out the results a little bit.  For example, what if I only wanted to export the &#8220;Active&#8221; incidents?  </p>
<p>In order to use a filter in your export, you append the following parameter in the URL:  &#8220;sysparm_query&#8221;.  For example, if you wanted to export all active incidents into XML, you would use the following URL:</p>
<blockquote><p>http://myinstance.service-now.com/incident.do?XML&#038;sysparm_query=active=true</p></blockquote>
<p>Let&#8217;s say you also want to only show those incidents where the category field is set to &#8220;hardware&#8221;.  You can add this field to the query by using the &#8220;^&#8221; character between filter fields.  Here is this example below:</p>
<blockquote><p>http://myinstance.service-now.com/incident.do?XML&#038;sysparm_query=active=true^category=hardware</p></blockquote>
<p>Now let&#8217;s say we want to group those results by priority such that the priority 1 items will all be shown together (and so on for all other priorities). In order to do this, you use the keyword:  EQ^GROUPBY just before the field that you wish to group results to.  See the example below:</p>
<blockquote><p>http://myinstance.service-now.com/incident.do?XML&#038;sysparm_query=active=true^category=hardware^EQ^GROUPBYpriority</p></blockquote>
<p>For an added bonus, you can make all of your exported reference fields show display values instead of ID numbers for their target tables by adding the following parameter to your URL:  &#8220;displayvalue=true&#8221;.</p>
<p>If we wished to do this for our filtered group created in this article, we could simply append the parameter to the url like so:</p>
<blockquote><p>http://myinstance.service-now.com/incident.do?XML&#038;sysparm_query=active=true^category=hardware^EQ^GROUPBYpriority&#038;displayvalue=true</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/filters-groups-in-service-now-urls.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling Large SOAP Messages in Service-now</title>
		<link>http://www.john-james-andersen.com/blog/service-now/handling-large-soap-messages-in-service-now.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/handling-large-soap-messages-in-service-now.html#comments</comments>
		<pubDate>Wed, 30 Jun 2010 19:59:29 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=467</guid>
		<description><![CDATA[I recently noticed that when I had large SOAP messages coming through the ECC Queue in my Service-now instance, that it was placing the payload of the message into an attachment record on the sys_attachment table. The attachment was named &#8220;payload.txt&#8221;. When this occurs the actual payload field in the ecc queue entry contains an [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.john-james-andersen.com/wp-content/uploads/soap.png" alt="" title="soap" width="338" height="231" class="aligncenter size-full wp-image-468" /></p>
<p>I recently noticed that when I had large SOAP messages coming through the ECC Queue in my Service-now instance, that it was placing the payload of the message into an attachment record on the sys_attachment table.  The attachment was named &#8220;payload.txt&#8221;.  </p>
<p>When this occurs the actual payload field in the ecc queue entry contains an empty xml tag: &#8220;&lt;see_attachment/&gt;&#8221;</p>
<p>By default, if the SOAP Payload size is over 512KB this attachment method kicks in for the Payload text.</p>
<p>You can adjust the trigger for this by going to your system properties and modifying the following property:</p>
<blockquote><p>glide.soapprocessor.large_field_patch_max</p></blockquote>
<p>The field is an integer and it represents the size in Bytes.  </p>
<p>By changing the property to be:  2000000, attachments will not be created for ECC Queue payloads if they are under 2MB.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/handling-large-soap-messages-in-service-now.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Digest Authentication with Service-now</title>
		<link>http://www.john-james-andersen.com/blog/service-now/digest-authentication-with-service-now.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/digest-authentication-with-service-now.html#comments</comments>
		<pubDate>Tue, 15 Jun 2010 13:26:13 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=464</guid>
		<description><![CDATA[I just completed a new training video around Digested Token Single Sign-on mechanisms and how you set up a service-now.com instance to utilize this method of Single Sign-on. I will be embedding it into the Service-now.com SSO wiki page later today. This video is a good primer for anyone looking to learn about Digested Token [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.john-james-andersen.com/wp-content/uploads/dsso.png" alt="Digest Authentication Training" title="Digest Authentication Training" width="443" height="261" class="aligncenter size-full wp-image-463" /></p>
<p>I just completed a new training video around Digested Token Single Sign-on mechanisms and how you set up a service-now.com instance to utilize this method of Single Sign-on.</p>
<p>I will be embedding it into the <a href="http://wiki.service-now.com/index.php?title=External_Authentication_(Single_Sign-On_-_SSO)#Digest_Authentication">Service-now.com SSO wiki page</a> later today.  </p>
<p>This video is a good primer for anyone looking to learn about Digested Token Authentication regardless of the technology they use.</p>
<p><object width="580" height="360"><param name="movie" value="http://www.youtube.com/v/1u7-sBadfW4&#038;hl=en_US&#038;fs=1&#038;rel=0&#038;hd=1&#038;border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/1u7-sBadfW4&#038;hl=en_US&#038;fs=1&#038;rel=0&#038;hd=1&#038;border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="580" height="360"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/digest-authentication-with-service-now.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Password Reset incident via HTTP Post with Service-now</title>
		<link>http://www.john-james-andersen.com/blog/service-now/create-a-password-reset-incident-via-http-post-with-service-now.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/create-a-password-reset-incident-via-http-post-with-service-now.html#comments</comments>
		<pubDate>Mon, 17 May 2010 18:52:20 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=451</guid>
		<description><![CDATA[Sure, Service-now.com is powerful when it comes to the web service, api, and other integration capabilities. Let&#8217;s say however, that you just want to create a method by which any HTTP enabled device could create a simple incident in your Service-now.com instance. You don&#8217;t want to have to authenticate&#8230;you just want to create an incident. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.john-james-andersen.com/wp-content/uploads/padlock.png" alt="" title="Password Reset" width="337" height="292" class="aligncenter size-full wp-image-452" /></p>
<p>Sure, Service-now.com is powerful when it comes to the web service, api, and other integration capabilities.  Let&#8217;s say however, that you just want to create a method by which any HTTP enabled device could create a simple incident in your Service-now.com instance.  You don&#8217;t want to have to authenticate&#8230;you just want to create an incident.</p>
<p>Security concerns &#8211; that is beyond this discussion other than to say you are allowing anyone to create a specific incident into your system. </p>
<p>Here is how you can go about enabling your service-now.com instance to allow these types of HTTP -> Incident requests.  For this example we will use a &#8220;Password Reset&#8221; scenario.</p>
<p>Overview of Objective:  I want to create an incident for a user that tells service-now.com that we need to reset that user&#8217;s password.  This will be only through a simple HTTP request (eg. https://myinstance.service-now.com/URLIncident.do?USER=john.andersen).</p>
<p>First off, we are going to create a UI Page that is publicly accessible to the world.  We are going to name that UI Page:  &#8220;URLIncident&#8221;.  At this point, leave your URLIncident UI Page at it&#8217;s default values.  Save your UI Page, we&#8217;ll come back to it later.  </p>
<p>Now we need to make that page a Public Page.  In order to do this, you go to the Public Pages module in the &#8220;System Definition&#8221; application and add one for your URLIncident. (Please note: if your &#8220;Public Pages&#8221; module is not visible you may have to enable it:  See <a href="http://wiki.service-now.com/index.php?title=Making_a_Survey_Public#Activate_the_Public_Pages_Module">&#8220;Activate the Public Pages Module&#8221;</a> on the Serivce-now.com wiki.</p>
<p>Of course, a public client-side UI Page cannot talk to our server libraries.  However, Service-now.com allows you to write Script Include files that are Client Callable through the <a href="http://wiki.service-now.com/index.php?title=GlideAjax">GlideAjax</a> library.  In this example, we will name the Script Include: &#8220;URLIncident&#8221; just like our UI Page. Make sure your Script Include is set to be &#8220;Client Callable&#8221;.</p>
<p>Here is the following script for your Script Include:</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> URLIncident <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
URLIncident.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> Object.<span style="color: #660066;">extendsObject</span><span style="color: #009900;">&#40;</span>AbstractAjaxProcessor<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; createIncident <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; user_name <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sysparm_user_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; gs.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Creating Password Reset incident for &quot;</span> <span style="color: #339933;">+</span> user_name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; inc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GlideRecord<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;incident&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; inc.<span style="color: #660066;">caller_id</span> <span style="color: #339933;">=</span> user_name<span style="color: #339933;">;</span><br />
&nbsp; inc.<span style="color: #660066;">short_description</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Reset Password for user &quot;</span> <span style="color: #339933;">+</span> user_name<span style="color: #339933;">;</span><br />
&nbsp; inc.<span style="color: #660066;">impact</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span><br />
&nbsp; inc.<span style="color: #660066;">urgency</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span><br />
&nbsp; inc.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
<br />
_privateFunction <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// this function is not client callable</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>This code essentially takes an Ajax parameter (&#8220;user_name&#8221;) and creates and incident with &#8220;user_name&#8221; as the caller_id and as the target individual in the short description.</p>
<p>Now we will revisit our UI Page and add a client script to the page so that it will get run when the URL is accessed.</p>
<p>This will be your Client Script for the page:</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//This will get the username out of a ?USER=john.andersen GET parameter</span><br />
getParams <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">search</span><span style="color: #339933;">;</span><br />
username <span style="color: #339933;">=</span> getParams.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\?USER\=/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Set up the Ajax Call</span><br />
<span style="color: #003366; font-weight: bold;">var</span> ga <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GlideAjax<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'URLIncident'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
ga.<span style="color: #660066;">addParam</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sysparm_name'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'createIncident'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
ga.<span style="color: #660066;">addParam</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sysparm_user_name'</span><span style="color: #339933;">,</span> username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Call the server-side Ajax script include</span><br />
ga.<span style="color: #660066;">getXMLWait</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Now, in order to test your setup, go to a browser that is not logged into your instance.  If you had a user with a username of &#8220;john.andersen&#8221;, and your instance was &#8220;myinstance&#8221;, you would type the following URL into your browser:</p>
<p>https://myinstance.service-now.com/URLIncident.do?USER=john.andersen</p>
<p>You should be shown a blank page.  </p>
<p>Now, in another browser that is logged into your Service-now.com instance, browse to your incident table and you should see a new Password Reset request for john.andersen.</p>
<p>Here is a quick video to demo this in action:</p>
<p><object width="550" height="480"><param name="movie" value="http://www.youtube.com/v/jF6G49VO7dg&#038;hl=en_US&#038;fs=1&#038;rel=0&#038;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jF6G49VO7dg&#038;hl=en_US&#038;fs=1&#038;rel=0&#038;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="550" height="480"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/create-a-password-reset-incident-via-http-post-with-service-now.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Weekday Scheduled Imports in Service-Now</title>
		<link>http://www.john-james-andersen.com/blog/service-now/setting-weekday-scheduled-imports.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/setting-weekday-scheduled-imports.html#comments</comments>
		<pubDate>Fri, 07 May 2010 14:41:50 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=439</guid>
		<description><![CDATA[Currently, Service-now.com doesn&#8217;t have a way to easily schedule data imports for weekdays only. You can do Daily, Weekly (on a day of the week), Monthly, Periodically, etc. However, if you want to do every week day, you are kind of out of luck. You could Create five Weekly Imports all for a different weekday, [...]]]></description>
			<content:encoded><![CDATA[<p>Currently, Service-now.com doesn&#8217;t have a way to easily schedule data imports for weekdays only.  You can do Daily, Weekly (on a day of the week), Monthly, Periodically, etc.  However, if you want to do every week day, you are kind of out of luck.</p>
<p>You <em>could</em>  Create five Weekly Imports all for a different weekday, but that gets a little cumbersome &#8212; especially if you have more than one scheduled data import.</p>
<p>I worked up another way this morning that might be useful.  This method will use a Post-Script on a <strong>Daily</strong> Scheduled Data Import.  After it runs the first time it will determine what day of the week it is.  If it is a Friday, then it will set the “run_start” field to the following Monday’s date with the same time.   This will cause the daily import to wait until Monday to run again.  I have a sample script that does this below:</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:350px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GlideRecord<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;scheduled_import_set&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
gr.<span style="color: #660066;">addQuery</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #000066;">NAME</span> OF YOUR SCHEDULED <span style="color: #003366; font-weight: bold;">IMPORT</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
gr.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
gr.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> run_start <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Packages.<span style="color: #660066;">com</span>.<span style="color: #660066;">glide</span>.<span style="color: #660066;">glideobject</span>.<span style="color: #660066;">GlideDateTime</span><span style="color: #009900;">&#40;</span>gr.<span style="color: #660066;">run_start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Get Seconds of the original time so that</span><br />
<span style="color: #006600; font-style: italic;">//we can preserve the original time in our new date</span><br />
<span style="color: #003366; font-weight: bold;">var</span> seconds <span style="color: #339933;">=</span> run_start.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getNumericValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #CC0000;">1000</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> today <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> thisDay <span style="color: #339933;">=</span> today.<span style="color: #660066;">getDay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns 0 for Sunday, 1 for Monday, etc.</span><br />
<span style="color: #003366; font-weight: bold;">var</span> thisMon <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Packages.<span style="color: #660066;">com</span>.<span style="color: #660066;">glide</span>.<span style="color: #660066;">glideobject</span>.<span style="color: #660066;">GlideDateTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
thisMon.<span style="color: #660066;">setDisplayValue</span><span style="color: #009900;">&#40;</span>gs.<span style="color: #660066;">beginningOfNextWeek</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>thisDay <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">//We are past Thursday...if this is running on a Friday</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">//we want the next run to be on the following Monday</span><br />
&nbsp; run_start.<span style="color: #660066;">setNumericValue</span><span style="color: #009900;">&#40;</span>thisMon.<span style="color: #660066;">getNumericValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Subtract the current time from itself so that we start at 0:00:00 for time</span><br />
run_start.<span style="color: #660066;">subtract</span><span style="color: #009900;">&#40;</span>run_start.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//We want to add the seconds for the time that </span><br />
<span style="color: #006600; font-style: italic;">//the job was origianlly scheduled for so that</span><br />
<span style="color: #006600; font-style: italic;">//we preserve the start time.</span><br />
run_start.<span style="color: #660066;">addSeconds</span><span style="color: #009900;">&#40;</span>seconds<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
gr.<span style="color: #660066;">run_start</span> <span style="color: #339933;">=</span> run_start<span style="color: #339933;">;</span><br />
gr.<span style="color: #660066;">update</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/setting-weekday-scheduled-imports.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating tables that extend another table in Javascript</title>
		<link>http://www.john-james-andersen.com/blog/service-now/creating-tables-that-extend-another-table-in-javascript.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/creating-tables-that-extend-another-table-in-javascript.html#comments</comments>
		<pubDate>Mon, 03 May 2010 14:14:54 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=436</guid>
		<description><![CDATA[There have been a few times that I have needed to create a table that extends a system table. However, Service-now.com doesn&#8217;t allow the extension of some of their system tables through the UI. I have found a way to do this programmatically. Please use good judgement on this since there was probably a good [...]]]></description>
			<content:encoded><![CDATA[<p>There have been a few times that I have needed to create a table that extends a system table.  However, Service-now.com doesn&#8217;t allow the extension of some of their system tables through the UI.  I have found a way to do this programmatically.</p>
<p>Please use good judgement on this since there was probably a good reason for dis-allowing the extension of system tables.</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//First line creates the table</span><br />
<span style="color: #006600; font-style: italic;">// parameters: </span><br />
<span style="color: #006600; font-style: italic;">// - Table Name </span><br />
<span style="color: #006600; font-style: italic;">// - Table Label</span><br />
<span style="color: #006600; font-style: italic;">// - Add sys fields (created by, updated, etc... &nbsp;make false when extending since they already exist)</span><br />
<span style="color: #006600; font-style: italic;">// - extended table (just make it an empty string if not extending any table</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> newtable <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Packages.<span style="color: #660066;">com</span>.<span style="color: #660066;">glide</span>.<span style="color: #660066;">db</span>.<span style="color: #660066;">TableCreateUtil</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;u_eloqua_field_import&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Eloqua Field Import&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;sys_import_set_row&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// This saves what you did in an update set.</span><br />
<span style="color: #003366; font-weight: bold;">new</span> Packages.<span style="color: #660066;">com</span>.<span style="color: #660066;">glide</span>.<span style="color: #660066;">update</span>.<span style="color: #660066;">saver</span>.<span style="color: #660066;">TableUpdateSaver</span><span style="color: #009900;">&#40;</span>newtable<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/creating-tables-that-extend-another-table-in-javascript.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting an XMLDocument Node to a String</title>
		<link>http://www.john-james-andersen.com/blog/service-now/converting-an-xmldocument-node-to-a-string.html</link>
		<comments>http://www.john-james-andersen.com/blog/service-now/converting-an-xmldocument-node-to-a-string.html#comments</comments>
		<pubDate>Thu, 29 Apr 2010 21:07:47 +0000</pubDate>
		<dc:creator>John Andersen</dc:creator>
				<category><![CDATA[Service-Now]]></category>

		<guid isPermaLink="false">http://www.john-james-andersen.com/?p=431</guid>
		<description><![CDATA[I recently need to take part of an XML document and convert that portion to a string. The problem is Service-now.com javascript libraries currently don&#8217;t have a way to let you select a node in your xml document and change that node and its children to a text representation of an xml document with that [...]]]></description>
			<content:encoded><![CDATA[<p>I recently need to take part of an XML document and convert that portion to a string.  The problem is Service-now.com javascript libraries currently don&#8217;t have a way to let you select a node in your xml document and change that node and its children to a text representation of an xml document with that node being a parent.</p>
<p>I finally decided to have my javascript access Java libraries to use a series of Java commands to convert my child node into a string.</p>
<p>For example, in the following XML string I want to extract, as a string, the &#8220;vitamins&#8221; node:</p>
<div class="codecolorer-container xml blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;food<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Avocado Dip<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mfr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Sunnydale<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mfr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;serving</span> <span style="color: #000066;">units</span>=<span style="color: #ff0000;">&quot;g&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>29<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/serving<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;calories</span> <span style="color: #000066;">total</span>=<span style="color: #ff0000;">&quot;110&quot;</span> <span style="color: #000066;">fat</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;total-fat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>11<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/total-fat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;saturated-fat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/saturated-fat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cholesterol<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cholesterol<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sodium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>210<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sodium<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;carb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/carb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fiber<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fiber<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;protein<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/protein<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vitamins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/c<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vitamins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;minerals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ca<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ca<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/minerals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/food<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Here is the function that I came up with:</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> convertXmlNodeToString<span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #006600; font-style: italic;">//</span><br />
<span style="color: #006600; font-style: italic;">// convert an xml node into a string</span><br />
<span style="color: #006600; font-style: italic;">//</span><br />
<span style="color: #006600; font-style: italic;">// PARMS</span><br />
<span style="color: #006600; font-style: italic;">// node - a java xml node</span><br />
<span style="color: #006600; font-style: italic;">//</span><br />
<span style="color: #006600; font-style: italic;">// RETURNS</span><br />
<span style="color: #006600; font-style: italic;">// String representation of the xml node</span><br />
<span style="color: #006600; font-style: italic;">//</span><br />
<span style="color: #003366; font-weight: bold;">var</span> sw <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Packages.<span style="color: #660066;">java</span>.<span style="color: #660066;">io</span>.<span style="color: #660066;">StringWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> transformer <span style="color: #339933;">=</span> Packages.<span style="color: #660066;">javax</span>.<span style="color: #660066;">xml</span>.<span style="color: #660066;">transform</span>.<span style="color: #660066;">TransformerFactory</span>.<span style="color: #660066;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">newTransformer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
transformer.<span style="color: #660066;">setOutputProperty</span><span style="color: #009900;">&#40;</span>Packages.<span style="color: #660066;">javax</span>.<span style="color: #660066;">xml</span>.<span style="color: #660066;">transform</span>.<span style="color: #660066;">OutputKeys</span>.<span style="color: #660066;">OMIT_XML_DECLARATION</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;yes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> domSource <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Packages.<span style="color: #660066;">javax</span>.<span style="color: #660066;">xml</span>.<span style="color: #660066;">transform</span>.<span style="color: #660066;">dom</span>.<span style="color: #660066;">DOMSource</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> streamResult <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Packages.<span style="color: #660066;">javax</span>.<span style="color: #660066;">xml</span>.<span style="color: #660066;">transform</span>.<span style="color: #660066;">stream</span>.<span style="color: #660066;">StreamResult</span><span style="color: #009900;">&#40;</span>sw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
transformer.<span style="color: #660066;">transform</span><span style="color: #009900;">&#40;</span>domSource<span style="color: #339933;">,</span> streamResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">return</span> sw.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now I am able to use XPATH to browse to a child node in an XMLDocument object using getNode(xpath), and then convert that node to a string.</p>
<div class="codecolorer-container javascript blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//xmlstring is the xml blob that I displayed above</span><br />
<br />
<span style="color: #006600; font-style: italic;">//create an xml document</span><br />
<span style="color: #003366; font-weight: bold;">var</span> xmldoc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLDocument<span style="color: #009900;">&#40;</span>xmlstring<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Get the Vitamins node</span><br />
<span style="color: #003366; font-weight: bold;">var</span> vitaminNode <span style="color: #339933;">=</span> xmldoc.<span style="color: #660066;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//vitamins&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Convert that node and it's children to a string that I can reuse elsewhere</span><br />
<span style="color: #003366; font-weight: bold;">var</span> vitaminString <span style="color: #339933;">=</span> convertXmlNodeToString<span style="color: #009900;">&#40;</span>vitaminString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.john-james-andersen.com/blog/service-now/converting-an-xmldocument-node-to-a-string.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
