Skip to content

Commit 4dd0cf1

Browse files
committed
Address review
1 parent f2be981 commit 4dd0cf1

File tree

3 files changed

+37
-58
lines changed

3 files changed

+37
-58
lines changed

components/servicenow/actions/create-case/create-case.mjs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import servicenow from "../../servicenow.app.mjs";
33
export default {
44
key: "servicenow-create-case",
55
name: "Create Case",
6-
description: "Creates a new case record in ServiceNow.",
6+
description: "Creates a new case record in ServiceNow. [See the docs here](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/trouble-ticket-open-api.html#title_trouble-ticket-POST-ticket-tt).",
77
version: "0.0.1",
88
type: "action",
99
annotations: {
@@ -81,9 +81,7 @@ export default {
8181
comment,
8282
} = this;
8383

84-
if (!description) {
85-
throw new Error("Description is required.");
86-
}
84+
const channel = this.servicenow.buildChannel(channelName);
8785

8886
const notes = this.servicenow.buildNotes({
8987
workNote,
@@ -97,14 +95,16 @@ export default {
9795

9896
const response = await this.servicenow.createTroubleTicket({
9997
$,
100-
ticketType: "Case",
101-
name,
102-
description,
103-
severity,
104-
status,
105-
channelName,
106-
notes,
107-
relatedParties,
98+
data: {
99+
ticketType: "Case",
100+
name,
101+
description,
102+
severity,
103+
status,
104+
channel,
105+
notes,
106+
relatedParties,
107+
},
108108
});
109109

110110
$.export("$summary", "Successfully created a case.");

components/servicenow/actions/create-incident/create-incident.mjs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import servicenow from "../../servicenow.app.mjs";
33
export default {
44
key: "servicenow-create-incident",
55
name: "Create Incident",
6-
description: "Creates a new incident record in ServiceNow.",
6+
description: "Creates a new incident record in ServiceNow. [See the docs here](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/trouble-ticket-open-api.html#title_trouble-ticket-POST-ticket-tt).",
77
version: "0.0.1",
88
type: "action",
99
annotations: {
@@ -81,30 +81,30 @@ export default {
8181
comment,
8282
} = this;
8383

84-
if (!description) {
85-
throw new Error("Description is required.");
86-
}
87-
88-
const notes = this.servicenow.buildNotes({
89-
workNote,
90-
comment,
91-
});
84+
const channel = this.servicenow.buildChannel(contactMethod);
9285

9386
const relatedParties = this.servicenow.buildRelatedParties({
9487
customer: companyId,
9588
customer_contact: userId,
9689
});
9790

91+
const notes = this.servicenow.buildNotes({
92+
workNote,
93+
comment,
94+
});
95+
9896
const response = await this.servicenow.createTroubleTicket({
9997
$,
100-
ticketType: "Incident",
101-
name,
102-
description,
103-
severity,
104-
status,
105-
channelName: contactMethod,
106-
notes,
107-
relatedParties,
98+
data: {
99+
ticketType: "Incident",
100+
name,
101+
description,
102+
severity,
103+
status,
104+
channel,
105+
notes,
106+
relatedParties,
107+
},
108108
});
109109

110110
$.export("$summary", "Successfully created an incident.");

components/servicenow/servicenow.app.mjs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,37 @@ export default {
4343
channelName: {
4444
type: "string",
4545
label: "Channel Name",
46-
description: "The channel that the ticket was created through.",
46+
description: "The channel (`contact_type`) that the ticket was created through.",
4747
optional: true,
4848
},
4949
contactMethod: {
5050
type: "string",
51-
label: "Contact Name",
52-
description: "Method of contact that the ticket was created through.",
51+
label: "Contact Method",
52+
description: "Name of the contact method (`contact_type`) that the ticket was created through.",
5353
optional: true,
5454
},
5555
accountId: {
5656
type: "string",
5757
label: "Account ID",
58-
description: "Sys_id of the account related to the case.",
58+
description: "`Sys_id` of the account related to the case.",
5959
optional: true,
6060
},
6161
contactId: {
6262
type: "string",
6363
label: "Contact ID",
64-
description: "Sys_id of the contact related to the case.",
64+
description: "`Sys_id` of the contact related to the case.",
6565
optional: true,
6666
},
6767
companyId: {
6868
type: "string",
6969
label: "Company ID",
70-
description: "Sys_id of the company related to the incident.",
70+
description: "`Sys_id` of the company related to the incident.",
7171
optional: true,
7272
},
7373
userId: {
7474
type: "string",
7575
label: "User ID",
76-
description: "Sys_id of the user related to the incident.",
76+
description: "`Sys_id` of the user related to the incident.",
7777
optional: true,
7878
},
7979
workNote: {
@@ -148,29 +148,8 @@ export default {
148148
}));
149149
},
150150
async createTroubleTicket({
151-
$ = this,
152-
ticketType,
153-
name,
154-
description,
155-
severity,
156-
status,
157-
channelName,
158-
notes,
159-
relatedParties,
160-
extraFields,
151+
$ = this, data,
161152
} = {}) {
162-
const data = {
163-
notes,
164-
relatedParties,
165-
ticketType,
166-
...extraFields,
167-
name,
168-
description,
169-
severity,
170-
status,
171-
channel: this.buildChannel(channelName),
172-
};
173-
174153
return axios($, {
175154
method: "post",
176155
url: `${this.baseUrl()}/api/sn_ind_tsm_sdwan/ticket/troubleTicket`,

0 commit comments

Comments
 (0)