Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions components/servicenow/actions/create-case/create-case.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import servicenow from "../../servicenow.app.mjs";

export default {
key: "servicenow-create-case",
name: "Create Case",
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).",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
servicenow,
name: {
propDefinition: [
servicenow,
"name",
],
},
description: {
propDefinition: [
servicenow,
"description",
],
},
severity: {
propDefinition: [
servicenow,
"caseSeverity",
],
},
status: {
propDefinition: [
servicenow,
"status",
],
},
channelName: {
propDefinition: [
servicenow,
"channelName",
],
},
accountId: {
propDefinition: [
servicenow,
"accountId",
],
},
contactId: {
propDefinition: [
servicenow,
"contactId",
],
},
workNote: {
propDefinition: [
servicenow,
"workNote",
],
},
comment: {
propDefinition: [
servicenow,
"comment",
],
},
},
async run({ $ }) {
const {
name,
description,
severity,
status,
channelName,
accountId,
contactId,
workNote,
comment,
} = this;

const channel = this.servicenow.buildChannel(channelName);

const notes = this.servicenow.buildNotes({
workNote,
comment,
});

const relatedParties = this.servicenow.buildRelatedParties({
customer: accountId,
customer_contact: contactId,
});

const response = await this.servicenow.createTroubleTicket({
$,
data: {
ticketType: "Case",
name,
description,
severity,
status,
channel,
notes,
relatedParties,
},
});

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

return response;
},
};
114 changes: 114 additions & 0 deletions components/servicenow/actions/create-incident/create-incident.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import servicenow from "../../servicenow.app.mjs";

export default {
key: "servicenow-create-incident",
name: "Create Incident",
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).",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
servicenow,
name: {
propDefinition: [
servicenow,
"name",
],
},
description: {
propDefinition: [
servicenow,
"description",
],
},
severity: {
propDefinition: [
servicenow,
"incidentSeverity",
],
},
status: {
propDefinition: [
servicenow,
"status",
],
},
contactMethod: {
propDefinition: [
servicenow,
"contactMethod",
],
},
companyId: {
propDefinition: [
servicenow,
"companyId",
],
},
userId: {
propDefinition: [
servicenow,
"userId",
],
},
workNote: {
propDefinition: [
servicenow,
"workNote",
],
},
comment: {
propDefinition: [
servicenow,
"comment",
],
},
},
async run({ $ }) {
const {
name,
description,
severity,
status,
contactMethod,
companyId,
userId,
workNote,
comment,
} = this;

const channel = this.servicenow.buildChannel(contactMethod);

const relatedParties = this.servicenow.buildRelatedParties({
customer: companyId,
customer_contact: userId,
});

const notes = this.servicenow.buildNotes({
workNote,
comment,
});

const response = await this.servicenow.createTroubleTicket({
$,
data: {
ticketType: "Incident",
name,
description,
severity,
status,
channel,
notes,
relatedParties,
},
});

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

return response;
},
};
31 changes: 31 additions & 0 deletions components/servicenow/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const DEFAULT_SEVERITY_OPTIONS = [
{
label: "Critical",
value: "1",
},
{
label: "High",
value: "2",
},
{
label: "Moderate",
value: "3",
},
{
label: "Low",
value: "4",
},
];

const INCIDENT_SEVERITY_OPTIONS = [
...DEFAULT_SEVERITY_OPTIONS,
{
label: "Planning",
value: "5",
},
];

export default {
DEFAULT_SEVERITY_OPTIONS,
INCIDENT_SEVERITY_OPTIONS,
};
4 changes: 2 additions & 2 deletions components/servicenow/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/servicenow",
"version": "0.6.0",
"version": "0.7.0",
"description": "Pipedream servicenow Components",
"main": "servicenow.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
"@pipedream/platform": "^3.1.0"
}
}
Loading
Loading