33
33
For a complete list of comparison operators, see $script:ServiceNowOperator and use Name in your filter.
34
34
See the examples.
35
35
36
+ . PARAMETER FilterString
37
+ A string representation of the filter. This is useful when the filter is complex and hard to specify as an array.
38
+ Retrieve the filter string from the ServiceNow UI via right click on the filter and selecting 'Copy query'.
39
+
36
40
. PARAMETER Sort
37
41
Array or multidimensional array of fields to sort on.
38
42
Each array should be of the format @(field, asc/desc).
143
147
144
148
Get a specific record by number using the function alias
145
149
150
+ . EXAMPLE
151
+ Get-ServiceNowRecord -Table 'incident' -FilterString 'active=true^state=1'
152
+
153
+ Provide a filter string from the UI to get records where active is true and state is 1
154
+
146
155
. INPUTS
147
156
ID
148
157
@@ -165,6 +174,7 @@ function Get-ServiceNowRecord {
165
174
[Parameter (ParameterSetName = ' Table' , Mandatory )]
166
175
[Parameter (ParameterSetName = ' TableId' , Mandatory )]
167
176
[Parameter (ParameterSetName = ' TableParentId' )]
177
+ [Parameter (ParameterSetName = ' FilterString' , Mandatory )]
168
178
[Alias (' sys_class_name' )]
169
179
[string ] $Table ,
170
180
@@ -204,6 +214,10 @@ function Get-ServiceNowRecord {
204
214
[Parameter (ParameterSetName = ' TableParentId' )]
205
215
[object []] $Filter = @ (),
206
216
217
+ [Parameter (ParameterSetName = ' FilterString' , Mandatory )]
218
+ [Alias (' fs' )]
219
+ [string ] $FilterString ,
220
+
207
221
[Parameter (ParameterSetName = ' Table' )]
208
222
[Parameter (ParameterSetName = ' TableParentId' )]
209
223
[ValidateNotNullOrEmpty ()]
@@ -234,7 +248,6 @@ function Get-ServiceNowRecord {
234
248
process {
235
249
236
250
$thisParams = @ {
237
- Filter = $Filter
238
251
Property = $Property
239
252
Sort = $Sort
240
253
DisplayValue = $DisplayValue
@@ -246,13 +259,18 @@ function Get-ServiceNowRecord {
246
259
}
247
260
248
261
if ( $PSBoundParameters.ContainsKey (' Filter' ) ) {
262
+ $thisParams.Filter = $Filter
249
263
# # we always want the filter to be arrays separated by joins
250
264
if ( $Filter [0 ].GetType().Name -ne ' Object[]' ) {
251
265
#
252
266
$thisParams.Filter = , $Filter
253
267
}
254
268
}
255
269
270
+ if ( $FilterString ) {
271
+ $thisParams.FilterString = $FilterString
272
+ }
273
+
256
274
$addedSysIdProp = $false
257
275
# we need the sys_id value in order to get custom var data
258
276
# add it in if specific properties were requested and not part of the list
0 commit comments