@pipedream/servicenow 0.6.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/LICENSE +41 -0
- package/README.md +61 -0
- package/actions/create-table-record/create-table-record.mjs +123 -0
- package/actions/get-table-record-by-sysid/get-table-record-by-sysid.mjs +112 -0
- package/actions/get-table-records/get-table-records.mjs +137 -0
- package/actions/update-table-record/update-table-record.mjs +130 -0
- package/package.json +18 -0
- package/servicenow.app.mjs +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Pipedream Source Available License Version 1.0
|
|
2
|
+
|
|
3
|
+
This Pipedream Source Available License Agreement Version 1.0 (this “Agreement”) sets forth the terms on which Pipedream, Inc., a Delaware corporation (“Pipedream”) makes available certain software (the “Software”). By installing, downloading, accessing, using or distributing the Software, you agree to the terms of this Agreement. If you do not agree to such terms, you must not use the Software. If you are receiving the Software on behalf of a legal entity, you represent and warrant that you have the actual authority to agree to the terms and conditions of this Agreement on behalf of such entity. “Licensee” means you, an individual, or the entity on whose behalf you are receiving the Software.
|
|
4
|
+
|
|
5
|
+
LICENSE GRANT AND CONDITIONS.
|
|
6
|
+
|
|
7
|
+
1.1 License. Subject to the terms and conditions of this Agreement, Pipedream hereby grants to Licensee a non-exclusive, royalty-free, worldwide, non-transferable, non-sublicenseable license during the term of this Agreement to use, prepare modifications and derivative works, distribute (including without limitation in source code or object code form) and reproduce copies of the Software (the “License”). Licensee is not granted the right to, and Licensee shall not, exercise the License for an Excluded Purpose. For purposes of this Agreement, “Excluded Purpose” means any commercial use of the software including, but not limited to, making available any software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other online service that competes with the Software or any other Pipedream products or services.
|
|
8
|
+
|
|
9
|
+
1.2 Conditions. In consideration of the License, Licensee’s distribution of the Software is subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
a. Licensee must cause any Software modified by Licensee to carry prominent notices stating that Licensee modified the Software.
|
|
12
|
+
|
|
13
|
+
b. On each Software copy, Licensee shall reproduce and not remove or alter all Pipedream or third party copyright or other proprietary notices contained in the Software, and Licensee must provide this with each copy: “This software is made available by Pipedream, Inc., under the terms of the Pipedream Source Available License, Version 1.0 located at https://github.com/PipedreamHQ/pipedream/blob/master/LICENSE. By installing, downloading, accessing, using or distributing the Software, you agree to the terms of such License Agreement.”
|
|
14
|
+
|
|
15
|
+
1.3 Modifications. Licensee may add its own copyright notices to modifications made by Licensee and may provide additional or different license terms and conditions for use, reproduction, or distribution of Licensee’s modifications. While redistributing the Software or modifications thereof, Licensee may choose to offer, for a fee or free of charge, support, warranty, indemnity, or other obligations. Licensee, and not Pipedream, will be responsible for any such obligations.
|
|
16
|
+
|
|
17
|
+
1.4 No Sublicensing. The License does not include the right to sublicense the Software; provided, however, that any recipient to which Licensee provides the Software may exercise the License so long as such recipient agrees to the terms and conditions of this Agreement.
|
|
18
|
+
|
|
19
|
+
TERM AND TERMINATION.
|
|
20
|
+
|
|
21
|
+
This Agreement will continue unless and until earlier terminated as set forth herein. If Licensee breaches any of its conditions or obligations under this Agreement, this Agreement will terminate automatically and the License will terminate automatically and permanently.
|
|
22
|
+
|
|
23
|
+
INTELLECTUAL PROPERTY.
|
|
24
|
+
|
|
25
|
+
As between the parties, Pipedream retains all right, title, and interest in the Software, and all intellectual property rights therein. Pipedream hereby reserves all rights not expressly granted to Licensee in this Agreement. Pipedream reserves all rights in its trademarks and service marks, and no licenses thereto are granted by this Agreement.
|
|
26
|
+
|
|
27
|
+
DISCLAIMER.
|
|
28
|
+
|
|
29
|
+
PIPEDREAM HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE SOFTWARE.
|
|
30
|
+
|
|
31
|
+
LIMITATION OF LIABILITY.
|
|
32
|
+
|
|
33
|
+
PIPEDREAM WILL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND, INCLUDING BUT NOT LIMITED TO, LOST PROFITS OR ANY CONSEQUENTIAL, SPECIAL, INCIDENTAL, INDIRECT, OR DIRECT DAMAGES, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ARISING OUT OF THIS AGREEMENT. THE FOREGOING SHALL APPLY TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW.
|
|
34
|
+
|
|
35
|
+
GENERAL.
|
|
36
|
+
|
|
37
|
+
6.1 Governing Law. This Agreement will be governed by and interpreted in accordance with the laws of the state of California, without reference to its conflict of laws principles. If Licensee is located outside of the United States, any dispute, controversy or claim arising out of or relating to this Agreement will be referred to and finally determined by arbitration in accordance with the JAMS International Arbitration Rules. The tribunal will consist of one arbitrator. Judgment upon the award rendered by the arbitrator may be entered in any court having jurisdiction thereof. All disputes including arbitrations shall take place in Santa Clara County, California. The language to be used in any such proceedings shall be English.
|
|
38
|
+
|
|
39
|
+
6.2. Assignment. Licensee is not authorized to assign its rights under this Agreement to any third party. Pipedream may freely assign its rights under this Agreement to any third party.
|
|
40
|
+
|
|
41
|
+
6.3. Other. This Agreement is the entire agreement between the parties regarding the subject matter hereof. No amendment or modification of this Agreement will be valid or binding upon the parties unless made in writing and signed by the duly authorized representatives of both parties. In the event that any provision, including without limitation any condition, of this Agreement is held to be unenforceable, this Agreement and all licenses and rights granted hereunder will immediately terminate. Waiver by Pipedream of a breach of any provision of this Agreement or the failure by Pipedream to exercise any right hereunder will not be construed as a waiver of any subsequent breach of that right or as a waiver of any other right.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
The ServiceNow API lets developers access and manipulate records, manage workflows, and integrate with other services on its IT service management platform. These capabilities support automating tasks, syncing data across platforms, and boosting operational efficiencies.
|
|
4
|
+
|
|
5
|
+
# Getting Started
|
|
6
|
+
|
|
7
|
+
Before using the ServiceNow REST API from a workflow, configure **two** OAuth apps in your ServiceNow instance. These apps will grant access tokens to your users and authenticate requests to its REST API.
|
|
8
|
+
|
|
9
|
+
## Create an External Client OAuth App
|
|
10
|
+
|
|
11
|
+
First, sign into your [ServiceNow Developer Portal](https://developer.servicenow.com/dev.do#!/home) account to create or access an instance.
|
|
12
|
+
|
|
13
|
+
1. Go to **System OAuth > Application Registry**.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
2. Create a new app by selecting **New** in the top right corner.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
3. Choose **Create an OAuth API endpoint for external clients**:
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
4. Name your app, such as `Pipedream`. Use the default settings but specify the **Redirect URL**: `https://api.pipedream.com/connect/oauth/oa_g2oiqA/callback`.
|
|
26
|
+
|
|
27
|
+
5. Click **Create**. It will appear in the Application Registry once created.
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
### Create the OAuth Validator app
|
|
32
|
+
|
|
33
|
+
1. Copy the client ID and secret from the `Pipedream` app you created above.
|
|
34
|
+
2. Name this app `Pipedream OAuth Validator` and add the previously copied client ID and secret.
|
|
35
|
+
3. Set the grant type to **Authorization Code** and the **Token URL** to `oauth_token.do`.
|
|
36
|
+
4. Use the same **Redirect URL** as before.
|
|
37
|
+
|
|
38
|
+
5. Visit [Pipedream's account page](https://pipedream.com/accounts), and click **Click Here to Connect An App**. Search for **ServiceNow** and select it. Enter the client ID, client secret, and your instance name (e.g., `dev98042` from `https://dev98042.service-now.com/`).
|
|
39
|
+
|
|
40
|
+
6. Press **Connect**. A new window will prompt you to login to your ServiceNow instance, authorizing Pipedream's access to the ServiceNow REST API.
|
|
41
|
+
|
|
42
|
+
## ServiceNow Authorization Reference
|
|
43
|
+
|
|
44
|
+
[This ServiceNow doc](https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/security/concept/c_OAuthAuthorizationCodeFlow.html) outlines the flow you should implement.
|
|
45
|
+
|
|
46
|
+
## Additional Guidance For Hardened or Mature Instances
|
|
47
|
+
|
|
48
|
+
The standard instructions may not apply perfectly to customized or hardened ServiceNow instances. If you face a **504 Gateway Time-out** error or similar, consider these tips:
|
|
49
|
+
|
|
50
|
+
* Assign a dedicated role and service account for this integration.
|
|
51
|
+
* Ensure the role has ACLs configured for the `oauth_credential` table and other necessary tables.
|
|
52
|
+
|
|
53
|
+
# Example Use Cases
|
|
54
|
+
|
|
55
|
+
- **Incident Management Automation**: Automatically create incidents in ServiceNow from alerts in Datadog or New Relic.
|
|
56
|
+
- **HR Onboarding Workflow**: Trigger a Pipedream workflow to set up new employee accounts in ServiceNow from HR systems like Workday.
|
|
57
|
+
- **Customer Support Ticket Sync**: Keep customer support tickets synced between ServiceNow and CRM platforms like Salesforce.
|
|
58
|
+
|
|
59
|
+
# Troubleshooting
|
|
60
|
+
|
|
61
|
+
If you encounter a **504 Gateway Time-out** error, refer to the 'Additional Guidance For Hardened or Mature Instances' section for solutions.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// legacy_hash_id: a_k6irW7
|
|
2
|
+
import { axios } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "servicenow-create-table-record",
|
|
6
|
+
name: "Create Table Record",
|
|
7
|
+
description: "Inserts one record in the specified table.",
|
|
8
|
+
version: "0.1.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
servicenow: {
|
|
12
|
+
type: "app",
|
|
13
|
+
app: "servicenow",
|
|
14
|
+
},
|
|
15
|
+
table_name: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "The name of the table where the record will be created.",
|
|
18
|
+
},
|
|
19
|
+
table_record: {
|
|
20
|
+
type: "object",
|
|
21
|
+
description: "The table record object. Use name-value pairs for each field of the record.",
|
|
22
|
+
},
|
|
23
|
+
api_version: {
|
|
24
|
+
type: "string",
|
|
25
|
+
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.",
|
|
26
|
+
optional: true,
|
|
27
|
+
options: [
|
|
28
|
+
"lastest",
|
|
29
|
+
"v1",
|
|
30
|
+
"v2",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
request_format: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Format of REST request body",
|
|
36
|
+
optional: true,
|
|
37
|
+
options: [
|
|
38
|
+
"application/json",
|
|
39
|
+
"application/xml",
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
response_format: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description: "Format of REST response body.",
|
|
45
|
+
optional: true,
|
|
46
|
+
options: [
|
|
47
|
+
"application/json",
|
|
48
|
+
"application/xml",
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
x_no_response_body: {
|
|
52
|
+
type: "boolean",
|
|
53
|
+
description: "By default, responses include body content detailing the modified record. Set this request header to true to suppress the response body.",
|
|
54
|
+
optional: true,
|
|
55
|
+
},
|
|
56
|
+
sysparm_display_value: {
|
|
57
|
+
type: "string",
|
|
58
|
+
description: "Return field display values (true), actual values (false), or both (all) (default: false).",
|
|
59
|
+
optional: true,
|
|
60
|
+
options: [
|
|
61
|
+
"true",
|
|
62
|
+
"false",
|
|
63
|
+
"all",
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
sysparm_exclude_reference_link: {
|
|
67
|
+
type: "boolean",
|
|
68
|
+
description: "Flag that indicates whether to exclude Table API links for reference fields.\n* `true`: Exclude Table API links for reference fields.\n* `false`: Include Table API links for reference fields.",
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
sysparm_fields: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "A comma-separated list of fields to return in the response.",
|
|
74
|
+
optional: true,
|
|
75
|
+
},
|
|
76
|
+
sysparm_input_display_value: {
|
|
77
|
+
type: "boolean",
|
|
78
|
+
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.",
|
|
79
|
+
optional: true,
|
|
80
|
+
},
|
|
81
|
+
sysparm_view: {
|
|
82
|
+
type: "string",
|
|
83
|
+
description: "Render the response according to the specified UI view (overridden by sysparm_fields).",
|
|
84
|
+
optional: true,
|
|
85
|
+
options: [
|
|
86
|
+
"desktop",
|
|
87
|
+
"mobile",
|
|
88
|
+
"both",
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
async run({ $ }) {
|
|
93
|
+
// See the API docs: https://docs.servicenow.com/bundle/paris-application-development/page/integrate/inbound-rest/concept/c_TableAPI.html#table-POST
|
|
94
|
+
|
|
95
|
+
if (!this.table_name || !this.table_record) {
|
|
96
|
+
throw new Error("Must provide table_name, and table_record parameters.");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var apiVersion = "";
|
|
100
|
+
if (this.api_version == "v1" || this.api_version == "v2") {
|
|
101
|
+
apiVersion = this.api_version + "/";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return await axios($, {
|
|
105
|
+
method: "post",
|
|
106
|
+
url: `https://${this.servicenow.$auth.instance_name}.service-now.com/api/now/${apiVersion}table/${this.table_name}`,
|
|
107
|
+
headers: {
|
|
108
|
+
"Authorization": `Bearer ${this.servicenow.$auth.oauth_access_token}`,
|
|
109
|
+
"Accept": this.request_format || "application/json",
|
|
110
|
+
"Content-Type": this.response_format || "application/json",
|
|
111
|
+
"X-no-response-body": this.x_no_response_body,
|
|
112
|
+
},
|
|
113
|
+
params: {
|
|
114
|
+
sysparm_display_value: this.sysparm_display_value,
|
|
115
|
+
sysparm_exclude_reference_link: this.sysparm_exclude_reference_link,
|
|
116
|
+
sysparm_fields: this.sysparm_fields,
|
|
117
|
+
sysparm_input_display_value: this.sysparm_input_display_value,
|
|
118
|
+
sysparm_view: this.sysparm_view,
|
|
119
|
+
},
|
|
120
|
+
data: this.table_record,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// legacy_hash_id: a_rJid2e
|
|
2
|
+
import { axios } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "servicenow-get-table-record-by-sysid",
|
|
6
|
+
name: "Get Table Record By SysId",
|
|
7
|
+
description: "Retrieves the record identified by the specified sys_id from the specified table.",
|
|
8
|
+
version: "0.3.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
servicenow: {
|
|
12
|
+
type: "app",
|
|
13
|
+
app: "servicenow",
|
|
14
|
+
},
|
|
15
|
+
table_name: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "The name of the table containing the record to retrieve.",
|
|
18
|
+
},
|
|
19
|
+
sys_id: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Unique identifier of the record to retrieve.",
|
|
22
|
+
},
|
|
23
|
+
api_version: {
|
|
24
|
+
type: "string",
|
|
25
|
+
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.",
|
|
26
|
+
optional: true,
|
|
27
|
+
options: [
|
|
28
|
+
"lastest",
|
|
29
|
+
"v1",
|
|
30
|
+
"v2",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
request_format: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Format of REST request body",
|
|
36
|
+
optional: true,
|
|
37
|
+
options: [
|
|
38
|
+
"application/json",
|
|
39
|
+
"application/xml",
|
|
40
|
+
"text/xml",
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
response_format: {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "Format of REST response body.",
|
|
46
|
+
optional: true,
|
|
47
|
+
options: [
|
|
48
|
+
"application/json",
|
|
49
|
+
"application/xml",
|
|
50
|
+
"text/xml",
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
sysparm_display_value: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "Return field display values (true), actual values (false), or both (all) (default: false).",
|
|
56
|
+
optional: true,
|
|
57
|
+
options: [
|
|
58
|
+
"true",
|
|
59
|
+
"false",
|
|
60
|
+
"all",
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
sysparm_exclude_reference_link: {
|
|
64
|
+
type: "boolean",
|
|
65
|
+
description: "True to exclude Table API links for reference fields (default: false).",
|
|
66
|
+
optional: true,
|
|
67
|
+
},
|
|
68
|
+
sysparm_fields: {
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "A comma-separated list of fields to return in the response.",
|
|
71
|
+
optional: true,
|
|
72
|
+
},
|
|
73
|
+
sysparm_view: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "Render the response according to the specified UI view (overridden by sysparm_fields).",
|
|
76
|
+
optional: true,
|
|
77
|
+
},
|
|
78
|
+
sysparm_query_no_domain: {
|
|
79
|
+
type: "boolean",
|
|
80
|
+
description: "True to access data across domains if authorized (default: false).",
|
|
81
|
+
optional: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
async run({ $ }) {
|
|
85
|
+
// See the API docs: https://docs.servicenow.com/bundle/paris-application-development/page/integrate/inbound-rest/concept/c_TableAPI.html#table-GET-id */
|
|
86
|
+
|
|
87
|
+
if (!this.table_name || !this.sys_id) {
|
|
88
|
+
throw new Error("Must provide table_name, and sys_id parameters.");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var apiVersion = "";
|
|
92
|
+
if (this.api_version == "v1" || this.api_version == "v2") {
|
|
93
|
+
apiVersion = this.api_version + "/";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return await axios($, {
|
|
97
|
+
url: `https://${this.servicenow.$auth.instance_name}.service-now.com/api/now/${apiVersion}table/${this.table_name}/${this.sys_id}`,
|
|
98
|
+
headers: {
|
|
99
|
+
"Authorization": `Bearer ${this.servicenow.$auth.oauth_access_token}`,
|
|
100
|
+
"Accept": this.request_format || "application/json",
|
|
101
|
+
"Content-Type": this.response_format || "application/json",
|
|
102
|
+
},
|
|
103
|
+
params: {
|
|
104
|
+
sysparm_display_value: this.sysparm_display_value,
|
|
105
|
+
sysparm_exclude_reference_link: this.sysparm_exclude_reference_link,
|
|
106
|
+
sysparm_fields: this.sysparm_fields,
|
|
107
|
+
sysparm_view: this.sysparm_view,
|
|
108
|
+
sysparm_query_no_domain: this.sysparm_query_no_domain,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// legacy_hash_id: a_wdid84
|
|
2
|
+
import { axios } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "servicenow-get-table-records",
|
|
6
|
+
name: "Get Table Records",
|
|
7
|
+
description: "Retrieves multiple records for the specified table.",
|
|
8
|
+
version: "0.3.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
servicenow: {
|
|
12
|
+
type: "app",
|
|
13
|
+
app: "servicenow",
|
|
14
|
+
},
|
|
15
|
+
table_name: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "The name of the table containing the records to retrieve.",
|
|
18
|
+
},
|
|
19
|
+
api_version: {
|
|
20
|
+
type: "string",
|
|
21
|
+
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.",
|
|
22
|
+
optional: true,
|
|
23
|
+
options: [
|
|
24
|
+
"lastest",
|
|
25
|
+
"v1",
|
|
26
|
+
"v2",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
request_format: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Format of REST request body",
|
|
32
|
+
optional: true,
|
|
33
|
+
options: [
|
|
34
|
+
"application/json",
|
|
35
|
+
"application/xml",
|
|
36
|
+
"text/xml",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
response_format: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "Format of REST response body.",
|
|
42
|
+
optional: true,
|
|
43
|
+
options: [
|
|
44
|
+
"application/json",
|
|
45
|
+
"application/xml",
|
|
46
|
+
"text/xml",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
sysparm_query: {
|
|
50
|
+
type: "string",
|
|
51
|
+
optional: true,
|
|
52
|
+
},
|
|
53
|
+
sysparm_display_value: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "Return field display values (true), actual values (false), or both (all) (default: false).",
|
|
56
|
+
optional: true,
|
|
57
|
+
options: [
|
|
58
|
+
"true",
|
|
59
|
+
"false",
|
|
60
|
+
"all",
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
sysparm_exclude_reference_link: {
|
|
64
|
+
type: "boolean",
|
|
65
|
+
description: "True to exclude Table API links for reference fields (default: false).",
|
|
66
|
+
optional: true,
|
|
67
|
+
},
|
|
68
|
+
sysparm_suppress_pagination_header: {
|
|
69
|
+
type: "boolean",
|
|
70
|
+
description: "True to supress pagination header (default: false).",
|
|
71
|
+
optional: true,
|
|
72
|
+
},
|
|
73
|
+
sysparm_fields: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "A comma-separated list of fields to return in the response.",
|
|
76
|
+
optional: true,
|
|
77
|
+
},
|
|
78
|
+
sysparm_limit: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "The maximum number of results returned per page (default: 10,000).",
|
|
81
|
+
optional: true,
|
|
82
|
+
},
|
|
83
|
+
sysparm_view: {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "Render the response according to the specified UI view (overridden by sysparm_fields).",
|
|
86
|
+
optional: true,
|
|
87
|
+
},
|
|
88
|
+
sysparm_query_category: {
|
|
89
|
+
type: "string",
|
|
90
|
+
description: "Name of the query category (read replica category) to use for queries.",
|
|
91
|
+
optional: true,
|
|
92
|
+
},
|
|
93
|
+
sysparm_query_no_domain: {
|
|
94
|
+
type: "boolean",
|
|
95
|
+
description: "True to access data across domains if authorized (default: false).",
|
|
96
|
+
optional: true,
|
|
97
|
+
},
|
|
98
|
+
sysparm_no_count: {
|
|
99
|
+
type: "boolean",
|
|
100
|
+
description: "Do not execute a select count(*) on table (default: false).",
|
|
101
|
+
optional: true,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
async run({ $ }) {
|
|
105
|
+
// See the API docs: https://docs.servicenow.com/bundle/paris-application-development/page/integrate/inbound-rest/concept/c_TableAPI.html#table-GET-id */
|
|
106
|
+
|
|
107
|
+
if (!this.table_name) {
|
|
108
|
+
throw new Error("Must provide table_name parameter.");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var apiVersion = "";
|
|
112
|
+
if (this.api_version == "v1" || this.api_version == "v2") {
|
|
113
|
+
apiVersion = this.api_version + "/";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return await axios($, {
|
|
117
|
+
url: `https://${this.servicenow.$auth.instance_name}.service-now.com/api/now/${apiVersion}table/${this.table_name}`,
|
|
118
|
+
headers: {
|
|
119
|
+
"Authorization": `Bearer ${this.servicenow.$auth.oauth_access_token}`,
|
|
120
|
+
"Accept": this.request_format || "application/json",
|
|
121
|
+
"Content-Type": this.response_format || "application/json",
|
|
122
|
+
},
|
|
123
|
+
params: {
|
|
124
|
+
sysparm_query: this.sysparm_query,
|
|
125
|
+
sysparm_display_value: this.sysparm_display_value,
|
|
126
|
+
sysparm_exclude_reference_link: this.sysparm_exclude_reference_link,
|
|
127
|
+
sysparm_suppress_pagination_header: this.sysparm_suppress_pagination_header,
|
|
128
|
+
sysparm_fields: this.sysparm_fields,
|
|
129
|
+
sysparm_limit: this.sysparm_limit,
|
|
130
|
+
sysparm_view: this.sysparm_view,
|
|
131
|
+
sysparm_query_category: this.sysparm_query_category,
|
|
132
|
+
sysparm_query_no_domain: this.sysparm_query_no_domain,
|
|
133
|
+
sysparm_no_count: this.sysparm_no_count,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// legacy_hash_id: a_4riE2J
|
|
2
|
+
import { axios } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "servicenow-update-table-record",
|
|
6
|
+
name: "Update Table Record",
|
|
7
|
+
description: "Updates the specified record with the name-value pairs included in the request body.",
|
|
8
|
+
version: "0.1.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
servicenow: {
|
|
12
|
+
type: "app",
|
|
13
|
+
app: "servicenow",
|
|
14
|
+
},
|
|
15
|
+
table_name: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "The name of the table containing the record to update.",
|
|
18
|
+
},
|
|
19
|
+
sys_id: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Unique identifier of the record to update.",
|
|
22
|
+
},
|
|
23
|
+
update_fields: {
|
|
24
|
+
type: "object",
|
|
25
|
+
description: "An object with name-value pairs with the fields to update in the specified record.\n**Note:** All fields within a record may not be available for update. For example, fields that have a prefix of \"sys_\" are typically system parameters that are automatically generated and cannot be updated.",
|
|
26
|
+
},
|
|
27
|
+
api_version: {
|
|
28
|
+
type: "string",
|
|
29
|
+
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.",
|
|
30
|
+
optional: true,
|
|
31
|
+
options: [
|
|
32
|
+
"lastest",
|
|
33
|
+
"v1",
|
|
34
|
+
"v2",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
request_format: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "Format of REST request body",
|
|
40
|
+
optional: true,
|
|
41
|
+
options: [
|
|
42
|
+
"application/json",
|
|
43
|
+
"application/xml",
|
|
44
|
+
"text/xml",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
response_format: {
|
|
48
|
+
type: "string",
|
|
49
|
+
description: "Format of REST response body.",
|
|
50
|
+
optional: true,
|
|
51
|
+
options: [
|
|
52
|
+
"application/json",
|
|
53
|
+
"application/xml",
|
|
54
|
+
"text/xml",
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
x_no_response_body: {
|
|
58
|
+
type: "boolean",
|
|
59
|
+
description: "By default, responses include body content detailing the modified record. Set this request header to true to suppress the response body.",
|
|
60
|
+
optional: true,
|
|
61
|
+
},
|
|
62
|
+
sysparm_display_value: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "Return field display values (true), actual values (false), or both (all) (default: false).",
|
|
65
|
+
optional: true,
|
|
66
|
+
options: [
|
|
67
|
+
"true",
|
|
68
|
+
"false",
|
|
69
|
+
"all",
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
sysparm_fields: {
|
|
73
|
+
type: "string",
|
|
74
|
+
description: "A comma-separated list of fields to return in the response.",
|
|
75
|
+
optional: true,
|
|
76
|
+
},
|
|
77
|
+
sysparm_input_display_value: {
|
|
78
|
+
type: "boolean",
|
|
79
|
+
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.",
|
|
80
|
+
optional: true,
|
|
81
|
+
},
|
|
82
|
+
sysparm_view: {
|
|
83
|
+
type: "string",
|
|
84
|
+
description: "Render the response according to the specified UI view (overridden by sysparm_fields).",
|
|
85
|
+
optional: true,
|
|
86
|
+
options: [
|
|
87
|
+
"desktop",
|
|
88
|
+
"mobile",
|
|
89
|
+
"both",
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
sysparm_query_no_domain: {
|
|
93
|
+
type: "boolean",
|
|
94
|
+
description: "True to access data across domains if authorized (default: false).",
|
|
95
|
+
optional: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
async run({ $ }) {
|
|
99
|
+
/* See the API docs: https://docs.servicenow.com/bundle/paris-application-development/page/integrate/inbound-rest/concept/c_TableAPI.html#c_TableAPI
|
|
100
|
+
Section Table - PATCH /now/table/{tableName}/{sys_id} */
|
|
101
|
+
|
|
102
|
+
if (!this.table_name || !this.sys_id || !this.update_fields) {
|
|
103
|
+
throw new Error("Must provide table_name, sys_id, and update_fields parameters.");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var apiVersion = "";
|
|
107
|
+
if (this.api_version == "v1" || this.api_version == "v2") {
|
|
108
|
+
apiVersion = this.api_version + "/";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return await axios($, {
|
|
112
|
+
method: "patch",
|
|
113
|
+
url: `https://${this.servicenow.$auth.instance_name}.service-now.com/api/now/${apiVersion}table/${this.table_name}/${this.sys_id}`,
|
|
114
|
+
headers: {
|
|
115
|
+
"Authorization": `Bearer ${this.servicenow.$auth.oauth_access_token}`,
|
|
116
|
+
"Accept": this.request_format || "application/json",
|
|
117
|
+
"Content-Type": this.response_format || "application/json",
|
|
118
|
+
"X-no-response-body": this.x_no_response_body,
|
|
119
|
+
},
|
|
120
|
+
params: {
|
|
121
|
+
sysparm_display_value: this.sysparm_display_value,
|
|
122
|
+
sysparm_fields: this.sysparm_fields,
|
|
123
|
+
sysparm_input_display_value: this.sysparm_input_display_value,
|
|
124
|
+
sysparm_view: this.sysparm_view,
|
|
125
|
+
sysparm_query_no_domain: this.sysparm_query_no_domain,
|
|
126
|
+
},
|
|
127
|
+
data: this.update_fields,
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipedream/servicenow",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Pipedream servicenow Components",
|
|
5
|
+
"main": "servicenow.app.mjs",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pipedream",
|
|
8
|
+
"servicenow"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://pipedream.com/apps/servicenow",
|
|
11
|
+
"author": "Pipedream support@pipedream.com (https://pipedream.com/)",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^3.0.0"
|
|
17
|
+
}
|
|
18
|
+
}
|