<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Script Syntax</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>Recent changes to Script Syntax</description><atom:link href="https://sourceforge.net/p/servicenowpump/wiki/Script%20Syntax/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 24 Sep 2013 16:25:00 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/servicenowpump/wiki/Script%20Syntax/feed" rel="self" type="application/rss+xml"/><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v18
+++ v19
@@ -32,6 +32,7 @@

 In addition, a &lt;tt&gt;minus&lt;/tt&gt; or/or &lt;tt&gt;plus&lt;/tt&gt; clause can be appended to a datetime. The syntax is as follows:

+    :::text
      [ minus  { days | hours | minutes | seconds } ]
                [ plus   { days | hours | minutes | seconds } ] 

@@ -51,6 +52,7 @@

 ### Syntax

+    :::text
     load  [ into   ] [ use-keys | no-keys ] [ truncate ]
         [ insert-only | update-insert | compare-timestamps ]
         [ [ created | updated ] from   [ to   ] ] 
@@ -122,6 +124,7 @@

 ### Syntax

+    :::text
     refresh  [ into  ] 
         since  
         [ where "{"  "}" ] 
@@ -130,10 +133,12 @@

 Note that this &lt;tt&gt;refresh&lt;/tt&gt; command:

+    :::text
     refresh change_request since today

 performs exactly the same function as this &lt;tt&gt;load&lt;/tt&gt; command:

+    :::text
     load change_request updated from today to now

 ## refresh every
@@ -144,6 +149,7 @@

 ### Syntax

+    :::text
     refresh  [ into  ] 
         [ since  ] 
         every  { seconds | minutes | hours } 
@@ -189,6 +195,7 @@

 ### Syntax

+    :::text
     prune  [ into  ] since 

 ### Examples
@@ -201,12 +208,14 @@

 ### Syntax

+    :::text
     prune  [ into  ] 
         [ since   ]
         every  { seconds | minutes | hours } 

 ### Examples

+    :::text
     prune change_task into upcoming_change_task every 60 minutes

 ## sql
@@ -215,6 +224,7 @@

 ### Syntax

+    :::text
     sql "{"  "}" 

 ### Examples
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Tue, 24 Sep 2013 16:25:00 -0000</pubDate><guid>https://sourceforge.nete9c52c049df0f87094ffe1d9ed5ef3a00b679c7c</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v17
+++ v18
@@ -159,7 +159,7 @@

 ### since

-Used to specify a starting date/time for the initial query. The &lt;i&gt;datetime&lt;/i&gt; may specified using the format &lt;i&gt;yyyy-mm-dd hh:mm:ss&lt;/i&gt; or using the keyword &lt;tt&gt;today&lt;/tt&gt; or &lt;tt&gt;now&lt;/tt&gt;.   All dates must be specified in GMT. The keyword &lt;tt&gt;today&lt;/tt&gt; will be interpreted as midnight GMT.
+Used to specify a starting date/time for the initial query. The &lt;i&gt;datetime&lt;/i&gt; may specified using the format &lt;i&gt;yyyy-mm-dd hh:mm:ss&lt;/i&gt; or using the keyword &lt;tt&gt;today&lt;/tt&gt; or &lt;tt&gt;now&lt;/tt&gt;. If not specified then the default is &lt;tt&gt;now&lt;/tt&gt;.  All dates must be specified in GMT. The keyword &lt;tt&gt;today&lt;/tt&gt; will be interpreted as midnight GMT.

 ### where

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Thu, 08 Aug 2013 14:06:24 -0000</pubDate><guid>https://sourceforge.net298b7e519a224bbab8c6ecf560e5b354b182a6a9</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v16
+++ v17
@@ -15,8 +15,8 @@
 | Syntax | Description |
 |--------|-------------|
 | &lt;tt&gt;&amp;lt;tablename&amp;gt;&lt;/tt&gt; | Angled brackets indicate a name or value should be substituted. |
-| &lt;tt&gt;&amp;#91;&amp;nbsp;seconds&amp;nbsp;&amp;#124;&amp;nbsp;minutes&amp;nbsp;&amp;#124;&amp;nbsp;hours&amp;nbsp;]&lt;/tt&gt; | Square brackets indicate an optional choice.  One or none of the keyworks may be specified. |
-| &lt;tt&gt;{ output &amp;#124; append }&lt;/tt&gt; | Curly brackets indicate a mandatory choice.  One of the keywords must be specified. |
+| &lt;tt&gt;&amp;#91;&amp;nbsp;created&amp;nbsp;&amp;#124;&amp;nbsp;updated&amp;nbsp;]&lt;/tt&gt; | Square brackets indicate an optional choice.  One or none of the keyworks may be specified. |
+| &lt;tt&gt;{&amp;nbsp;seconds&amp;nbsp;&amp;#124;&amp;nbsp;minutes&amp;nbsp;&amp;#124;&amp;nbsp;hours&amp;nbsp;}&lt;/tt&gt; | Curly brackets indicate a mandatory choice.  One of the keywords must be specified. |
 | &lt;tt&gt;"{" &amp;lt;clause&amp;gt; "}"&lt;/tt&gt; | Quoted curly brackets indicate that the clause is to be specified between curly brackets. |

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Mon, 20 May 2013 15:45:26 -0000</pubDate><guid>https://sourceforge.net6d5fb27742d3e93748533059bade256a8bbb320d</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v15
+++ v16
@@ -10,8 +10,7 @@

 ### Syntax Notation

-The following notation is used on this wiki page for the syntax specifications below.
-
+The following notation is used on this page for the syntax specifications below.

 | Syntax | Description |
 |--------|-------------|
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Mon, 20 May 2013 15:39:59 -0000</pubDate><guid>https://sourceforge.net98eb28e5c26e5ac4696945d71d34022963ff18ef</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v14
+++ v15
@@ -16,7 +16,7 @@
 | Syntax | Description |
 |--------|-------------|
 | &lt;tt&gt;&amp;lt;tablename&amp;gt;&lt;/tt&gt; | Angled brackets indicate a name or value should be substituted. |
-| &lt;tt&gt;&amp;#91; created &amp;#124; updated ]&lt;/tt&gt; | Square brackets indicate an optional choice.  Either or neither of the keyworks may be specified. |
+| &lt;tt&gt;&amp;#91;&amp;nbsp;seconds&amp;nbsp;&amp;#124;&amp;nbsp;minutes&amp;nbsp;&amp;#124;&amp;nbsp;hours&amp;nbsp;]&lt;/tt&gt; | Square brackets indicate an optional choice.  One or none of the keyworks may be specified. |
 | &lt;tt&gt;{ output &amp;#124; append }&lt;/tt&gt; | Curly brackets indicate a mandatory choice.  One of the keywords must be specified. |
 | &lt;tt&gt;"{" &amp;lt;clause&amp;gt; "}"&lt;/tt&gt; | Quoted curly brackets indicate that the clause is to be specified between curly brackets. |

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Sun, 19 May 2013 20:48:14 -0000</pubDate><guid>https://sourceforge.netbb3d5dcecb4778a0dd0b7ed8d7da3b1490d2dfcc</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v13
+++ v14
@@ -190,7 +190,7 @@

 ### Syntax

-    prune  [ into  ] since  
+    prune  [ into  ] since 

 ### Examples

@@ -203,8 +203,8 @@
 ### Syntax

     prune  [ into  ] 
-        [ since  ]
-        every  { seconds | minutes | hours } 
+        [ since   ]
+        every  { seconds | minutes | hours } 

 ### Examples

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Sun, 19 May 2013 20:45:17 -0000</pubDate><guid>https://sourceforge.net084dfbb7a5e6cb7ba5a843a1f41653ebbd161049</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v12
+++ v13
@@ -16,8 +16,8 @@
 | Syntax | Description |
 |--------|-------------|
 | &lt;tt&gt;&amp;lt;tablename&amp;gt;&lt;/tt&gt; | Angled brackets indicate a name or value should be substituted. |
-| &lt;tt&gt;\[ created \| updated \]&lt;/tt&gt; | Square brackets indicate an optional choice.  Either or neither of the keyworks may be specified. |
-| &lt;tt&gt;{ output \| append }&lt;/tt&gt; | Curly brackets indicate a mandatory choice.  One of the keywords must be specified. |
+| &lt;tt&gt;&amp;#91; created &amp;#124; updated ]&lt;/tt&gt; | Square brackets indicate an optional choice.  Either or neither of the keyworks may be specified. |
+| &lt;tt&gt;{ output &amp;#124; append }&lt;/tt&gt; | Curly brackets indicate a mandatory choice.  One of the keywords must be specified. |
 | &lt;tt&gt;"{" &amp;lt;clause&amp;gt; "}"&lt;/tt&gt; | Quoted curly brackets indicate that the clause is to be specified between curly brackets. |

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Sun, 19 May 2013 20:43:38 -0000</pubDate><guid>https://sourceforge.net30bedf407831746ffc96525a94255aabb37c8673</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v11
+++ v12
@@ -7,33 +7,19 @@

     -f 

+
 ### Syntax Notation

 The following notation is used on this wiki page for the syntax specifications below.

-&lt;table&gt;
-&lt;tr align="left"&gt;
-  &lt;th&gt;Syntax&lt;/th&gt;
-  &lt;th&gt;Description&lt;/th&gt;
-&lt;/tr&gt;
-&lt;tr&gt;
-  &lt;td&gt;&lt;tt&gt;&amp;lt;tablename&amp;gt;&lt;/tt&gt;&lt;/td&gt;
-  &lt;td&gt;Angled brackets indicate a name or value should be substituted.&lt;/td&gt;
-&lt;/tr&gt;
-&lt;tr&gt;
-  &lt;td&gt;&lt;tt&gt;[ created | updated ]&lt;/tt&gt;&lt;/td&gt;
-  &lt;td&gt;Square brackets indicate an optional choice.  Either or neither of the keyworks may be specified.&lt;/td&gt;
-&lt;/tr&gt;
-&lt;tr&gt;
-  &lt;td&gt;&lt;tt&gt;{ output | append }&lt;/tt&gt;&lt;/td&gt;
-  &lt;td&gt;Curly brackets indicate a andatory choice.  One of the keywords must be specified.
-&lt;/td&gt;
-&lt;/tr&gt;
-&lt;tr&gt;
-  &lt;td&gt;&lt;tt&gt;"{" &amp;lt;clause&amp;gt; "}"&lt;/tt&gt;&lt;/td&gt;
-  &lt;td&gt;Quoted curly brackets indicate that the clause is to be specified between curly brackets.&lt;/td&gt;
-&lt;/tr&gt;
-&lt;/table&gt;
+
+| Syntax | Description |
+|--------|-------------|
+| &lt;tt&gt;&amp;lt;tablename&amp;gt;&lt;/tt&gt; | Angled brackets indicate a name or value should be substituted. |
+| &lt;tt&gt;\[ created \| updated \]&lt;/tt&gt; | Square brackets indicate an optional choice.  Either or neither of the keyworks may be specified. |
+| &lt;tt&gt;{ output \| append }&lt;/tt&gt; | Curly brackets indicate a mandatory choice.  One of the keywords must be specified. |
+| &lt;tt&gt;"{" &amp;lt;clause&amp;gt; "}"&lt;/tt&gt; | Quoted curly brackets indicate that the clause is to be specified between curly brackets. |
+

 ### DateTime Notation

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Sun, 19 May 2013 20:38:08 -0000</pubDate><guid>https://sourceforge.net3fb726ca9340cb68f732ec3975224426fe50faa4</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v10
+++ v11
@@ -107,28 +107,22 @@

 The following command will load all Linux servers into a SQL table named &lt;tt&gt;linux_server&lt;/tt&gt;. The SQL table will be created if it does not already exist. If it exists and contains data then records from ServiceNow will be inserted and/or updated based on the primary key which is  &lt;tt&gt;sys_id&lt;/tt&gt;.

-~~~~
-load cmdb_ci_linux_server into linux_server
-~~~~
+    load cmdb_ci_linux_server into linux_server

 The following script will load all &lt;tt&gt;change_request&lt;/tt&gt; tickets from the first half of 2012, one month at a time starting with the most recent month.

-~~~~
-load change_request from 2012-06-01 to 2012-07-01
-load change_request from 2012-05-01 to 2012-06-01
-load change_request from 2012-04-01 to 2012-05-01
-load change_request from 2012-03-01 to 2012-04-01
-load change_request from 2012-02-01 to 2012-03-01
-load change_request from 2012-01-01 to 2012-02-01
-~~~~
+    load change_request from 2012-06-01 to 2012-07-01
+    load change_request from 2012-05-01 to 2012-06-01
+    load change_request from 2012-04-01 to 2012-05-01
+    load change_request from 2012-03-01 to 2012-04-01
+    load change_request from 2012-02-01 to 2012-03-01
+    load change_request from 2012-01-01 to 2012-02-01

 The following script will load all records from the tables &lt;tt&gt;sys_user&lt;/tt&gt;, &lt;tt&gt;sys_user_group&lt;/tt&gt; and &lt;tt&gt;sys_user_grmember&lt;/tt&gt;. Existing records in   &lt;tt&gt;sys_user&lt;/tt&gt; and &lt;tt&gt;sys_user_group&lt;/tt&gt; will be updated only if they have changed (based on timestamp). The table &lt;tt&gt;sys_user_grmember&lt;/tt&gt;  will be truncated and reloaded.

-~~~~
-load sys_user compare-timestamps
-load sys_user_group compare-timestamps
-load sys_user_grmember truncate
-~~~~
+    load sys_user compare-timestamps
+    load sys_user_group compare-timestamps
+    load sys_user_grmember truncate

 The following command will load all P1 "Network" incidents  updated in the last seven days through midnight GMT.

@@ -151,15 +145,11 @@

 Note that this &lt;tt&gt;refresh&lt;/tt&gt; command:

-~~~~
-refresh change_request since today
-~~~~
+    refresh change_request since today

 performs exactly the same function as this &lt;tt&gt;load&lt;/tt&gt; command:

-~~~~
-load change_request updated from today to now
-~~~~
+    load change_request updated from today to now

 ## refresh every

@@ -194,23 +184,19 @@

 The following example will load all P1 incidents created or updated since 5:30 PM (GMT) yesterday and then poll the system every 5 minutes for any newly created or updated P1 incidents. The application will continue running until it is killed. 

-~~~~
-load incident from today minus 390 minutes where { priority&lt;2 }
-refresh incident every 5 minutes where { priority&lt;2 }
-~~~~
+    load incident from today minus 390 minutes where { priority&lt;2 }
+    refresh incident every 5 minutes where { priority&lt;2 }

 The following example will load all upcoming change requests and change tasks into the the tables &lt;tt&gt;upcoming_change_request&lt;/tt&gt; and &lt;tt&gt;upcoming_change_task&lt;/tt&gt; respectively and then monitor the system every 10 minutes for any changes. The application will continue running until it is killed. This script will not correctly account for change requests or change tasks which are deleted after it starts running.  For that you need the  &lt;tt&gt;prune&lt;/tt&gt; operation (described below). 

-~~~~
-load    change_request into upcoming_change_request truncate \
-        where { start_date&gt;javascript:gs.daysAgoEnd(0) }
-load    change_task    into upcoming_change_task    truncate \
-        where { request.start_date&gt;javascript:gs.daysAgoEnd(0) }
-refresh change_request into upcoming_change_request every 10 minutes \
-        where { start_date&gt;javascript:gs.daysAgoEnd(0) }
-refresh change_task    into upcoming_change_task    every 10 minutes \
-        where { request.start_date&gt;javascript:gs.daysAgoEnd(0) }
-~~~~
+    load    change_request into upcoming_change_request truncate \
+            where { start_date&gt;javascript:gs.daysAgoEnd(0) }
+    load    change_task    into upcoming_change_task    truncate \
+            where { request.start_date&gt;javascript:gs.daysAgoEnd(0) }
+    refresh change_request into upcoming_change_request every 10 minutes \
+            where { start_date&gt;javascript:gs.daysAgoEnd(0) }
+    refresh change_task    into upcoming_change_task    every 10 minutes \
+            where { request.start_date&gt;javascript:gs.daysAgoEnd(0) }

 ## prune

@@ -222,9 +208,7 @@

 ### Examples

-~~~~
-prune change_task into upcoming_change_task since 2013-01-01
-~~~~
+    prune change_task into upcoming_change_task since 2013-01-01

 ## prune every

@@ -232,15 +216,13 @@

 ### Syntax

-    prune  [ into ] 
-        [ since  ] 
+    prune  [ into  ] 
+        [ since  ]
         every  { seconds | minutes | hours } 

 ### Examples

-~~~~
-prune change_task into upcoming_change_task every 60 minutes
-~~~~
+    prune change_task into upcoming_change_task every 60 minutes

 ## sql

@@ -252,40 +234,38 @@

 ### Examples

-~~~~
-sql { truncate table ritm_variable }
-
-
-sql { merge into ritm_variable t \
-using ( \
-select \
-v.sys_id sc_item_option, \
-ritm.sys_id sc_req_item, \
-ritm.number_, \
-vdef.name var_name, \
-v.value var_value, \
-vdef.reference ref_table, \
-vdef.question_text question_text \
-from  \
-sc_req_item ritm,  \
-sc_cat_item item, \
-sc_item_option_mtom iv,  \
-sc_item_option v, \
-item_option_new vdef \
-where ritm.opened_at &gt;= to_date('2012-07-01','yyyy-mm-dd') \
-and item.sys_id = ritm.cat_item \
-and iv.request_item = ritm.sys_id \
-and v.sys_id = iv.sc_item_option \
-and vdef.sys_id = v.item_option_new \
-) s \
-on (s.sc_item_option = t.sc_item_option) \
-when matched then update \
-set t.var_value = s.var_value \
-when not matched then insert ( \
-t.sc_item_option, t.sc_req_item, t.number_, \
-t.var_name, t.var_value, t.ref_table, t.question_text) \
-values ( \
-s.sc_item_option, s.sc_req_item, s.number_, \
-s.var_name, s.var_value, s.ref_table, s.question_text) } 
-~~~~
-
+    sql { truncate table ritm_variable }
+    
+    
+    sql { merge into ritm_variable t \
+    using ( \
+    select \
+    v.sys_id sc_item_option, \
+    ritm.sys_id sc_req_item, \
+    ritm.number_, \
+    vdef.name var_name, \
+    v.value var_value, \
+    vdef.reference ref_table, \
+    vdef.question_text question_text \
+    from  \
+    sc_req_item ritm,  \
+    sc_cat_item item, \
+    sc_item_option_mtom iv,  \
+    sc_item_option v, \
+    item_option_new vdef \
+    where ritm.opened_at &gt;= to_date('2012-07-01','yyyy-mm-dd') \
+    and item.sys_id = ritm.cat_item \
+    and iv.request_item = ritm.sys_id \
+    and v.sys_id = iv.sc_item_option \
+    and vdef.sys_id = v.item_option_new \
+    ) s \
+    on (s.sc_item_option = t.sc_item_option) \
+    when matched then update \
+    set t.var_value = s.var_value \
+    when not matched then insert ( \
+    t.sc_item_option, t.sc_req_item, t.number_, \
+    t.var_name, t.var_value, t.ref_table, t.question_text) \
+    values ( \
+    s.sc_item_option, s.sc_req_item, s.number_, \
+    s.var_name, s.var_value, s.ref_table, s.question_text) } 
+    
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Sun, 19 May 2013 20:07:04 -0000</pubDate><guid>https://sourceforge.net8c76d046679c4c828ab76dadbd9ce053f25576ed</guid></item><item><title>Script Syntax modified by Giles Lewis</title><link>https://sourceforge.net/p/servicenowpump/wiki/Script%2520Syntax/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v9
+++ v10
@@ -143,10 +143,9 @@

 ### Syntax

-   refresh   [ into  ] 
-           since  
-           [ where "{"  "}" ] 
-
+    refresh  [ into  ] 
+        since  
+        [ where "{"  "}" ] 

 ### Example

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giles Lewis</dc:creator><pubDate>Sun, 19 May 2013 20:03:47 -0000</pubDate><guid>https://sourceforge.net3998384db670a7f9627f7e2e9b8c00b3bea9d81d</guid></item></channel></rss>