@pipedream/servicenow 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/create-table-record/create-table-record.mjs +46 -97
- package/actions/delete-table-record/delete-table-record.mjs +53 -0
- package/actions/get-record-counts-by-field/get-record-counts-by-field.mjs +133 -0
- package/actions/get-table-record-by-id/get-table-record-by-id.mjs +77 -0
- package/actions/get-table-records/get-table-records.mjs +91 -98
- package/actions/update-table-record/update-table-record.mjs +61 -102
- package/common/utils.mjs +15 -0
- package/package.json +3 -3
- package/servicenow.app.mjs +137 -129
- package/actions/create-case/create-case.mjs +0 -114
- package/actions/create-incident/create-incident.mjs +0 -114
- package/actions/get-table-record-by-sysid/get-table-record-by-sysid.mjs +0 -117
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import servicenow from "../../servicenow.app.mjs";
|
|
2
|
+
import { parseObject } from "../../common/utils.mjs";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
key: "servicenow-create-table-record",
|
|
6
6
|
name: "Create Table Record",
|
|
7
|
-
description: "Inserts one record in the specified table.",
|
|
8
|
-
version: "0.
|
|
7
|
+
description: "Inserts one record in the specified table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-POST)",
|
|
8
|
+
version: "1.0.0",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -13,116 +13,65 @@ export default {
|
|
|
13
13
|
},
|
|
14
14
|
type: "action",
|
|
15
15
|
props: {
|
|
16
|
-
servicenow
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
description: "The name of the table where the record will be created.",
|
|
16
|
+
servicenow,
|
|
17
|
+
table: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
servicenow,
|
|
20
|
+
"table",
|
|
21
|
+
],
|
|
23
22
|
},
|
|
24
|
-
|
|
23
|
+
recordData: {
|
|
24
|
+
label: "Record Data",
|
|
25
25
|
type: "object",
|
|
26
|
-
description: "The
|
|
26
|
+
description: "The data to create the record with, as key-value pairs (e.g. `{ \"name\": \"John Doe\", \"email\": \"john.doe@example.com\" }`)",
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
options: [
|
|
33
|
-
"lastest",
|
|
34
|
-
"v1",
|
|
35
|
-
"v2",
|
|
28
|
+
responseDataFormat: {
|
|
29
|
+
propDefinition: [
|
|
30
|
+
servicenow,
|
|
31
|
+
"responseDataFormat",
|
|
36
32
|
],
|
|
37
33
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
options: [
|
|
43
|
-
"application/json",
|
|
44
|
-
"application/xml",
|
|
34
|
+
excludeReferenceLinks: {
|
|
35
|
+
propDefinition: [
|
|
36
|
+
servicenow,
|
|
37
|
+
"excludeReferenceLinks",
|
|
45
38
|
],
|
|
46
39
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
options: [
|
|
52
|
-
"application/json",
|
|
53
|
-
"application/xml",
|
|
40
|
+
responseFields: {
|
|
41
|
+
propDefinition: [
|
|
42
|
+
servicenow,
|
|
43
|
+
"responseFields",
|
|
54
44
|
],
|
|
55
45
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
sysparm_display_value: {
|
|
62
|
-
type: "string",
|
|
63
|
-
description: "Return field display values (true), actual values (false), or both (all) (default: false).",
|
|
64
|
-
optional: true,
|
|
65
|
-
options: [
|
|
66
|
-
"true",
|
|
67
|
-
"false",
|
|
68
|
-
"all",
|
|
46
|
+
inputDisplayValue: {
|
|
47
|
+
propDefinition: [
|
|
48
|
+
servicenow,
|
|
49
|
+
"inputDisplayValue",
|
|
69
50
|
],
|
|
70
51
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
sysparm_fields: {
|
|
77
|
-
type: "string",
|
|
78
|
-
description: "A comma-separated list of fields to return in the response.",
|
|
79
|
-
optional: true,
|
|
80
|
-
},
|
|
81
|
-
sysparm_input_display_value: {
|
|
82
|
-
type: "boolean",
|
|
83
|
-
description: "Flag that indicates whether to set field values using the display value or the actual value.\n* `true`: Treats input values as display values and they are manipulated so they can be stored properly in the database.\n* `false`: Treats input values as actual values and stored them in the database without manipulation.",
|
|
84
|
-
optional: true,
|
|
85
|
-
},
|
|
86
|
-
sysparm_view: {
|
|
87
|
-
type: "string",
|
|
88
|
-
description: "Render the response according to the specified UI view (overridden by sysparm_fields).",
|
|
89
|
-
optional: true,
|
|
90
|
-
options: [
|
|
91
|
-
"desktop",
|
|
92
|
-
"mobile",
|
|
93
|
-
"both",
|
|
52
|
+
responseView: {
|
|
53
|
+
propDefinition: [
|
|
54
|
+
servicenow,
|
|
55
|
+
"responseView",
|
|
94
56
|
],
|
|
95
57
|
},
|
|
96
58
|
},
|
|
97
59
|
async run({ $ }) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var apiVersion = "";
|
|
105
|
-
if (this.api_version == "v1" || this.api_version == "v2") {
|
|
106
|
-
apiVersion = this.api_version + "/";
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return await axios($, {
|
|
110
|
-
method: "post",
|
|
111
|
-
url: `https://${this.servicenow.$auth.instance_name}.service-now.com/api/now/${apiVersion}table/${this.table_name}`,
|
|
112
|
-
headers: {
|
|
113
|
-
"Authorization": `Bearer ${this.servicenow.$auth.oauth_access_token}`,
|
|
114
|
-
"Accept": this.request_format || "application/json",
|
|
115
|
-
"Content-Type": this.response_format || "application/json",
|
|
116
|
-
"X-no-response-body": this.x_no_response_body,
|
|
117
|
-
},
|
|
60
|
+
const response = await this.servicenow.createTableRecord({
|
|
61
|
+
$,
|
|
62
|
+
table: this.table,
|
|
63
|
+
data: parseObject(this.recordData),
|
|
118
64
|
params: {
|
|
119
|
-
sysparm_display_value: this.
|
|
120
|
-
sysparm_exclude_reference_link: this.
|
|
121
|
-
sysparm_fields: this.
|
|
122
|
-
sysparm_input_display_value: this.
|
|
123
|
-
sysparm_view: this.
|
|
65
|
+
sysparm_display_value: this.responseDataFormat,
|
|
66
|
+
sysparm_exclude_reference_link: this.excludeReferenceLinks,
|
|
67
|
+
sysparm_fields: this.responseFields?.join?.() || this.responseFields,
|
|
68
|
+
sysparm_input_display_value: this.inputDisplayValue,
|
|
69
|
+
sysparm_view: this.responseView,
|
|
124
70
|
},
|
|
125
|
-
data: this.table_record,
|
|
126
71
|
});
|
|
72
|
+
|
|
73
|
+
$.export("$summary", `Successfully created record in table "${this.table}"`);
|
|
74
|
+
|
|
75
|
+
return response;
|
|
127
76
|
},
|
|
128
77
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import servicenow from "../../servicenow.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "servicenow-delete-table-record",
|
|
5
|
+
name: "Delete Table Record",
|
|
6
|
+
description: "Deletes the specified record from a table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-DELETE)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: true,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
servicenow,
|
|
16
|
+
table: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
servicenow,
|
|
19
|
+
"table",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
recordId: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
servicenow,
|
|
25
|
+
"recordId",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
queryNoDomain: {
|
|
29
|
+
propDefinition: [
|
|
30
|
+
servicenow,
|
|
31
|
+
"queryNoDomain",
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
async run({ $ }) {
|
|
36
|
+
await this.servicenow.deleteTableRecord({
|
|
37
|
+
$,
|
|
38
|
+
table: this.table,
|
|
39
|
+
recordId: this.recordId,
|
|
40
|
+
params: {
|
|
41
|
+
sysparm_query_no_domain: this.queryNoDomain,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
$.export("$summary", `Successfully deleted record ${this.recordId} from table "${this.table}"`);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
success: true,
|
|
49
|
+
recordId: this.recordId,
|
|
50
|
+
table: this.table,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import servicenow from "../../servicenow.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "servicenow-get-record-counts-by-field",
|
|
6
|
+
name: "Get Record Counts by Field",
|
|
7
|
+
description: "Retrieves the count of records grouped by a specified field from a ServiceNow table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_AggregateAPI.html#title_aggregate-GET-stats)",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
type: "action",
|
|
15
|
+
props: {
|
|
16
|
+
servicenow,
|
|
17
|
+
table: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
servicenow,
|
|
20
|
+
"table",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
groupByField: {
|
|
24
|
+
type: "string",
|
|
25
|
+
label: "Group By Field",
|
|
26
|
+
description: "The field to group records by (e.g., `priority`, `state`, `category`)",
|
|
27
|
+
},
|
|
28
|
+
count: {
|
|
29
|
+
type: "boolean",
|
|
30
|
+
label: "Count",
|
|
31
|
+
description: "If true, returns the number of records returned by the query",
|
|
32
|
+
optional: true,
|
|
33
|
+
default: true,
|
|
34
|
+
},
|
|
35
|
+
query: {
|
|
36
|
+
label: "Query",
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "An [encoded query string](https://www.servicenow.com/docs/bundle/zurich-platform-user-interface/page/use/using-lists/concept/c_EncodedQueryStrings.html) to filter records before aggregation (e.g., `active=true^priority=1`)",
|
|
39
|
+
optional: true,
|
|
40
|
+
},
|
|
41
|
+
aggregateInfo: {
|
|
42
|
+
type: "alert",
|
|
43
|
+
alertType: "info",
|
|
44
|
+
content: "You must provide at least one Aggregate Field. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_AggregateAPI.html#title_aggregate-GET-stats) for more information.",
|
|
45
|
+
},
|
|
46
|
+
avgFields: {
|
|
47
|
+
type: "string[]",
|
|
48
|
+
label: "Average Aggregate Fields",
|
|
49
|
+
description: "Numeric fields to calculate averages for (e.g., `reassignment_count`, `reopen_count`)",
|
|
50
|
+
optional: true,
|
|
51
|
+
},
|
|
52
|
+
minFields: {
|
|
53
|
+
type: "string[]",
|
|
54
|
+
label: "Minimum Aggregate Fields",
|
|
55
|
+
description: "Numeric fields to find minimum values for",
|
|
56
|
+
optional: true,
|
|
57
|
+
},
|
|
58
|
+
maxFields: {
|
|
59
|
+
type: "string[]",
|
|
60
|
+
label: "Maximum Aggregate Fields",
|
|
61
|
+
description: "Numeric fields to find maximum values for",
|
|
62
|
+
optional: true,
|
|
63
|
+
},
|
|
64
|
+
sumFields: {
|
|
65
|
+
type: "string[]",
|
|
66
|
+
label: "Sum Aggregate Fields",
|
|
67
|
+
description: "Numeric fields to calculate sums for",
|
|
68
|
+
optional: true,
|
|
69
|
+
},
|
|
70
|
+
havingQuery: {
|
|
71
|
+
type: "string",
|
|
72
|
+
label: "Having Query",
|
|
73
|
+
description: "Filter the aggregated results (e.g., `COUNT>10` to only show groups with more than 10 records)",
|
|
74
|
+
optional: true,
|
|
75
|
+
},
|
|
76
|
+
responseDataFormat: {
|
|
77
|
+
propDefinition: [
|
|
78
|
+
servicenow,
|
|
79
|
+
"responseDataFormat",
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
orderBy: {
|
|
83
|
+
type: "string",
|
|
84
|
+
label: "Order By",
|
|
85
|
+
description: "Field to sort results by. Prefix with `^ORDER_BY` for ascending or `^ORDER_BYDESC` for descending (e.g., `^ORDER_BYDESC` + field name)",
|
|
86
|
+
optional: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
async run({ $ }) {
|
|
90
|
+
const params = {
|
|
91
|
+
sysparm_count: this.count,
|
|
92
|
+
sysparm_query: this.query,
|
|
93
|
+
sysparm_group_by: this.groupByField,
|
|
94
|
+
sysparm_display_value: this.responseDataFormat,
|
|
95
|
+
sysparm_having: this.havingQuery,
|
|
96
|
+
sysparm_order_by: this.orderBy,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
let hasAggregateFields = false;
|
|
100
|
+
|
|
101
|
+
// Add aggregate functions for each field type
|
|
102
|
+
if (this.avgFields?.length) {
|
|
103
|
+
params.sysparm_avg_fields = this.avgFields.join?.() || this.avgFields;
|
|
104
|
+
hasAggregateFields = true;
|
|
105
|
+
}
|
|
106
|
+
if (this.minFields?.length) {
|
|
107
|
+
params.sysparm_min_fields = this.minFields.join?.() || this.minFields;
|
|
108
|
+
hasAggregateFields = true;
|
|
109
|
+
}
|
|
110
|
+
if (this.maxFields?.length) {
|
|
111
|
+
params.sysparm_max_fields = this.maxFields.join?.() || this.maxFields;
|
|
112
|
+
hasAggregateFields = true;
|
|
113
|
+
}
|
|
114
|
+
if (this.sumFields?.length) {
|
|
115
|
+
params.sysparm_sum_fields = this.sumFields.join?.() || this.sumFields;
|
|
116
|
+
hasAggregateFields = true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!hasAggregateFields) {
|
|
120
|
+
throw new ConfigurationError("You must provide at least one Aggregate Field. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_AggregateAPI.html#title_aggregate-GET-stats) for more information.");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const response = await this.servicenow.getRecordCountsByField({
|
|
124
|
+
$,
|
|
125
|
+
table: this.table,
|
|
126
|
+
params,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
$.export("$summary", `Successfully retrieved ${response?.length || 0} records grouped by field "${this.groupByField}"`);
|
|
130
|
+
|
|
131
|
+
return response;
|
|
132
|
+
},
|
|
133
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import servicenow from "../../servicenow.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "servicenow-get-table-record-by-id",
|
|
5
|
+
name: "Get Table Record by ID",
|
|
6
|
+
description: "Retrieves a single record from a table by its ID. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-GET-id)",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
servicenow,
|
|
16
|
+
table: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
servicenow,
|
|
19
|
+
"table",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
recordId: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
servicenow,
|
|
25
|
+
"recordId",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
responseDataFormat: {
|
|
29
|
+
propDefinition: [
|
|
30
|
+
servicenow,
|
|
31
|
+
"responseDataFormat",
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
excludeReferenceLinks: {
|
|
35
|
+
propDefinition: [
|
|
36
|
+
servicenow,
|
|
37
|
+
"excludeReferenceLinks",
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
responseFields: {
|
|
41
|
+
propDefinition: [
|
|
42
|
+
servicenow,
|
|
43
|
+
"responseFields",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
responseView: {
|
|
47
|
+
propDefinition: [
|
|
48
|
+
servicenow,
|
|
49
|
+
"responseView",
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
queryNoDomain: {
|
|
53
|
+
propDefinition: [
|
|
54
|
+
servicenow,
|
|
55
|
+
"queryNoDomain",
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
async run({ $ }) {
|
|
60
|
+
const response = await this.servicenow.getTableRecordById({
|
|
61
|
+
$,
|
|
62
|
+
table: this.table,
|
|
63
|
+
recordId: this.recordId,
|
|
64
|
+
params: {
|
|
65
|
+
sysparm_display_value: this.responseDataFormat,
|
|
66
|
+
sysparm_exclude_reference_link: this.excludeReferenceLinks,
|
|
67
|
+
sysparm_fields: this.responseFields?.join?.() || this.responseFields,
|
|
68
|
+
sysparm_view: this.responseView,
|
|
69
|
+
sysparm_query_no_domain: this.queryNoDomain,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
$.export("$summary", `Successfully retrieved record ${this.recordId} from table "${this.table}"`);
|
|
74
|
+
|
|
75
|
+
return response;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import servicenow from "../../servicenow.app.mjs";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
key: "servicenow-get-table-records",
|
|
6
6
|
name: "Get Table Records",
|
|
7
|
-
description: "Retrieves multiple records for the specified table.",
|
|
8
|
-
version: "0.
|
|
7
|
+
description: "Retrieves multiple records for the specified table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-GET)",
|
|
8
|
+
version: "1.0.0",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -13,130 +13,123 @@ export default {
|
|
|
13
13
|
},
|
|
14
14
|
type: "action",
|
|
15
15
|
props: {
|
|
16
|
-
servicenow
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "The name of the table containing the records to retrieve.",
|
|
23
|
-
},
|
|
24
|
-
api_version: {
|
|
25
|
-
type: "string",
|
|
26
|
-
description: "API version number. Version numbers identify the endpoint version that a URI accesses. By specifying a version number in your URIs, you can ensure that future updates to the REST API do not negatively impact your integration. Use `lastest` to use the latest REST endpoint for your instance version.",
|
|
27
|
-
optional: true,
|
|
28
|
-
options: [
|
|
29
|
-
"lastest",
|
|
30
|
-
"v1",
|
|
31
|
-
"v2",
|
|
16
|
+
servicenow,
|
|
17
|
+
table: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
servicenow,
|
|
20
|
+
"table",
|
|
32
21
|
],
|
|
33
22
|
},
|
|
34
|
-
|
|
35
|
-
type: "
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
options: [
|
|
39
|
-
"application/json",
|
|
40
|
-
"application/xml",
|
|
41
|
-
"text/xml",
|
|
42
|
-
],
|
|
23
|
+
filterInfo: {
|
|
24
|
+
type: "alert",
|
|
25
|
+
alertType: "info",
|
|
26
|
+
content: "You must provide either a `Query` or at least one `Filter` prop. ",
|
|
43
27
|
},
|
|
44
|
-
|
|
28
|
+
query: {
|
|
29
|
+
label: "Query",
|
|
45
30
|
type: "string",
|
|
46
|
-
description: "
|
|
31
|
+
description: "An [encoded query string](https://www.servicenow.com/docs/bundle/zurich-platform-user-interface/page/use/using-lists/concept/c_EncodedQueryStrings.html) to filter records by (e.g., `active=true^priority=1`). This overrides any other filters set.",
|
|
47
32
|
optional: true,
|
|
48
|
-
options: [
|
|
49
|
-
"application/json",
|
|
50
|
-
"application/xml",
|
|
51
|
-
"text/xml",
|
|
52
|
-
],
|
|
53
33
|
},
|
|
54
|
-
|
|
34
|
+
filterCreatedAtDate: {
|
|
55
35
|
type: "string",
|
|
36
|
+
label: "Filter by Date Created",
|
|
37
|
+
description: "Return records created only after the given date, in the format `YYYY-MM-DD HH:MM:SS` (e.g. `2026-01-01 00:00:00`).",
|
|
56
38
|
optional: true,
|
|
57
39
|
},
|
|
58
|
-
|
|
40
|
+
filterUpdatedAtDate: {
|
|
59
41
|
type: "string",
|
|
60
|
-
|
|
42
|
+
label: "Filter by Date Updated",
|
|
43
|
+
description: "Return records updated only after the given date, in the format `YYYY-MM-DD HH:MM:SS` (e.g. `2026-01-01 00:00:00`).",
|
|
61
44
|
optional: true,
|
|
62
|
-
options: [
|
|
63
|
-
"true",
|
|
64
|
-
"false",
|
|
65
|
-
"all",
|
|
66
|
-
],
|
|
67
45
|
},
|
|
68
|
-
|
|
46
|
+
filterActive: {
|
|
69
47
|
type: "boolean",
|
|
70
|
-
|
|
48
|
+
label: "Filter by Active",
|
|
49
|
+
description: "If set to `true`, only return records that are active. If set to `false`, only return records that are inactive. May not be available for all tables.",
|
|
71
50
|
optional: true,
|
|
72
51
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
sysparm_fields: {
|
|
79
|
-
type: "string",
|
|
80
|
-
description: "A comma-separated list of fields to return in the response.",
|
|
81
|
-
optional: true,
|
|
52
|
+
responseDataFormat: {
|
|
53
|
+
propDefinition: [
|
|
54
|
+
servicenow,
|
|
55
|
+
"responseDataFormat",
|
|
56
|
+
],
|
|
82
57
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
excludeReferenceLinks: {
|
|
59
|
+
propDefinition: [
|
|
60
|
+
servicenow,
|
|
61
|
+
"excludeReferenceLinks",
|
|
62
|
+
],
|
|
87
63
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
64
|
+
responseFields: {
|
|
65
|
+
propDefinition: [
|
|
66
|
+
servicenow,
|
|
67
|
+
"responseFields",
|
|
68
|
+
],
|
|
92
69
|
},
|
|
93
|
-
|
|
94
|
-
type: "
|
|
95
|
-
|
|
70
|
+
limit: {
|
|
71
|
+
type: "integer",
|
|
72
|
+
label: "Limit",
|
|
73
|
+
description: "The maximum number of results to return",
|
|
74
|
+
min: 1,
|
|
75
|
+
default: 10000,
|
|
96
76
|
optional: true,
|
|
97
77
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
78
|
+
responseView: {
|
|
79
|
+
propDefinition: [
|
|
80
|
+
servicenow,
|
|
81
|
+
"responseView",
|
|
82
|
+
],
|
|
102
83
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
84
|
+
queryNoDomain: {
|
|
85
|
+
propDefinition: [
|
|
86
|
+
servicenow,
|
|
87
|
+
"queryNoDomain",
|
|
88
|
+
],
|
|
107
89
|
},
|
|
108
90
|
},
|
|
109
91
|
async run({ $ }) {
|
|
110
|
-
|
|
92
|
+
let query = this.query;
|
|
111
93
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
94
|
+
// If no query is provided, build one from the filters
|
|
95
|
+
if (!query) {
|
|
96
|
+
const filters = [];
|
|
97
|
+
|
|
98
|
+
if (this.filterCreatedAtDate) {
|
|
99
|
+
filters.push(`sys_created_on>=${this.filterCreatedAtDate}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (this.filterUpdatedAtDate) {
|
|
103
|
+
filters.push(`sys_updated_on>=${this.filterUpdatedAtDate}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (this.filterActive !== undefined) {
|
|
107
|
+
filters.push(`active=${this.filterActive}`);
|
|
108
|
+
}
|
|
115
109
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
if (!filters.length) {
|
|
111
|
+
throw new ConfigurationError("You must provide either a `Query` or at least one `Filter` prop.");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
query = filters.join("^");
|
|
119
115
|
}
|
|
120
116
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"Authorization": `Bearer ${this.servicenow.$auth.oauth_access_token}`,
|
|
125
|
-
"Accept": this.request_format || "application/json",
|
|
126
|
-
"Content-Type": this.response_format || "application/json",
|
|
127
|
-
},
|
|
117
|
+
const response = await this.servicenow.getTableRecords({
|
|
118
|
+
$,
|
|
119
|
+
table: this.table,
|
|
128
120
|
params: {
|
|
129
|
-
sysparm_query:
|
|
130
|
-
sysparm_display_value: this.
|
|
131
|
-
sysparm_exclude_reference_link: this.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
sysparm_query_category: this.sysparm_query_category,
|
|
137
|
-
sysparm_query_no_domain: this.sysparm_query_no_domain,
|
|
138
|
-
sysparm_no_count: this.sysparm_no_count,
|
|
121
|
+
sysparm_query: query,
|
|
122
|
+
sysparm_display_value: this.responseDataFormat,
|
|
123
|
+
sysparm_exclude_reference_link: this.excludeReferenceLinks,
|
|
124
|
+
sysparm_fields: this.responseFields?.join?.() || this.responseFields,
|
|
125
|
+
sysparm_limit: this.limit,
|
|
126
|
+
sysparm_view: this.responseView,
|
|
127
|
+
sysparm_query_no_domain: this.queryNoDomain,
|
|
139
128
|
},
|
|
140
129
|
});
|
|
130
|
+
|
|
131
|
+
$.export("$summary", `Successfully retrieved ${response?.length || 0} record(s) from table "${this.table}"`);
|
|
132
|
+
|
|
133
|
+
return response;
|
|
141
134
|
},
|
|
142
135
|
};
|