Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import servicenow from "../../servicenow.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "servicenow-add-item-to-cart",
name: "Add Item to Cart",
description: "Add a ServiceNow catalog item to the current user's cart. Run **Search Catalog Items** to find the item `sys_id` and **Get Catalog Item Variables** to learn which variable names to supply. After adding items, use **View Cart**, then **Checkout Cart** or **Submit Cart Order** to submit. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: false,
openWorldHint: true,
},
props: {
servicenow,
catalogItemSysId: {
propDefinition: [
servicenow,
"catalogItemSysId",
],
description: "The `sys_id` of the catalog item to add. Run **Search Catalog Items** first to find this value. Example: `e8d3d2f1c0a8016400e6b9e0f6e6f6e6`.",
},
quantity: {
propDefinition: [
servicenow,
"quantity",
],
},
variables: {
propDefinition: [
servicenow,
"variables",
],
},
requestedFor: {
propDefinition: [
servicenow,
"requestedFor",
],
},
},
async run({ $ }) {
const response = await this.servicenow.addItemToCart({
$,
catalogItemSysId: this.catalogItemSysId,
data: {
sysparm_quantity: this.quantity,
variables: parseObject(this.variables),
sysparm_requested_for: this.requestedFor,
},
});

$.export("$summary", `Successfully added catalog item ${this.catalogItemSysId} to cart`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import servicenow from "../../servicenow.app.mjs";
import { assertSafeQueryValue } from "../../common/utils.mjs";

export default {
key: "servicenow-check-order-status",
name: "Check Order Status",
description: "Retrieve the status of a ServiceNow catalog request (REQ) from the `sc_request` table, including request state, approval, and stage. Provide the request number returned by **Checkout Cart**, **Submit Cart Order**, or **Order Catalog Item**. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
props: {
servicenow,
requestNumber: {
Comment thread
vetrivigneshwaran marked this conversation as resolved.
type: "string",
label: "Request Number",
description: "The request number to look up (matched against `number` on `sc_request`). Example: `REQ0010001`.",
Comment thread
vetrivigneshwaran marked this conversation as resolved.
},
requestedFor: {
propDefinition: [
servicenow,
"requestedFor",
],
description: "Optional `sys_id` of the requested-for user to additionally filter by (matched against `requested_for` on `sc_request`). Run **Find Users** to find it.",
},
},
async run({ $ }) {
assertSafeQueryValue(this.requestNumber, "Request Number");
assertSafeQueryValue(this.requestedFor, "Requested For");

const queryParts = [
`number=${this.requestNumber}`,
];
if (this.requestedFor) {
queryParts.push(`requested_for=${this.requestedFor}`);
}
const response = await this.servicenow.getRequests({
$,
params: {
sysparm_query: queryParts.join("^"),
sysparm_limit: 1,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
});

const request = response?.[0];
let summary;
if (!request) {
summary = `No request found with number ${this.requestNumber}`;
} else {
const state = request.state ?? request.request_state;
summary = state
? `Retrieved status for request ${this.requestNumber}: ${state}`
: `Retrieved status for request ${this.requestNumber}`;
}
$.export("$summary", summary);

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

export default {
key: "servicenow-checkout-cart",
name: "Checkout Cart",
description: "Submit the current user's ServiceNow cart via the standard `/cart/checkout` endpoint, generating a request (REQ). The result depends on the instance's one-step vs two-step checkout configuration (in two-step mode it returns the order summary/status to confirm rather than finalizing). Add items first with **Add Item to Cart** and inspect with **View Cart**. Use **Check Order Status** afterward to track the resulting request. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: false,
openWorldHint: true,
},
props: {
servicenow,
},
async run({ $ }) {
const response = await this.servicenow.checkoutCart({
$,
});

const requestNumber = response?.request_number ?? response?.number ?? response?.request_id;
const summary = requestNumber
? `Successfully checked out cart - request ${requestNumber}`
: "Successfully checked out cart";
$.export("$summary", summary);

return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "servicenow-create-table-record",
name: "Create Table Record",
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)",
version: "1.0.3",
version: "1.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import servicenow from "../../servicenow.app.mjs";

export default {
key: "servicenow-delete-cart-item",
name: "Delete Cart Item",
description: "Remove an item from the current user's ServiceNow cart. Run **View Cart** first to obtain the `cart_item` id to delete. This permanently removes the line item from the cart. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: true,
openWorldHint: true,
},
props: {
servicenow,
cartItemId: {
type: "string",
label: "Cart Item ID",
description: "The cart item id to remove. Run **View Cart** first to find this value. Example: `0f3b2e2e1b223010d3f5a6c1cd4bcb12`.",
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
async run({ $ }) {
const response = await this.servicenow.deleteCartItem({
$,
cartItemId: this.cartItemId,
});

$.export("$summary", `Successfully removed cart item ${this.cartItemId}`);

return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "servicenow-delete-table-record",
name: "Delete Table Record",
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)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
31 changes: 31 additions & 0 deletions components/servicenow/actions/empty-cart/empty-cart.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import servicenow from "../../servicenow.app.mjs";

export default {
key: "servicenow-empty-cart",
name: "Empty Cart",
description: "Empty and delete the current user's ServiceNow cart, removing all of its items. The action resolves the active cart automatically, so no cart ID is required. Emptying a cart that still has items requires the `catalog_admin` role (a plain `admin` can only delete an already-empty cart). [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: true,
openWorldHint: true,
},
props: {
servicenow,
},
async run({ $ }) {
const { cart_id: cartSysId } = await this.servicenow.getCart({
$,
});

const response = await this.servicenow.emptyCart({
$,
cartSysId,
});

$.export("$summary", `Successfully emptied cart ${cartSysId}`);

return response;
},
};
66 changes: 66 additions & 0 deletions components/servicenow/actions/find-users/find-users.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import servicenow from "../../servicenow.app.mjs";
import { assertSafeQueryValue } from "../../common/utils.mjs";

export default {
key: "servicenow-find-users",
name: "Find Users",
description: "Search ServiceNow `sys_user` records to find a user's `sys_id` (used by props like the requested-for field on **Add Item to Cart**). Choose whether to match on name (partial) or email (exact). [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
props: {
servicenow,
searchField: {
type: "string",
label: "Search Field",
description: "Which `sys_user` field to match on. `Name` performs a partial (contains) match; `Email` requires an exact match.",
options: [
{
label: "Name (partial match)",
value: "name",
},
{
label: "Email (exact match)",
value: "email",
},
],
default: "name",
},
searchValue: {
type: "string",
label: "Search Value",
description: "The value to search for. Example: `Jane Doe` or `jane.doe@example.com`.",
},
limit: {
propDefinition: [
servicenow,
"limit",
],
},
},
async run({ $ }) {
assertSafeQueryValue(this.searchValue, "Search Value");

const operator = this.searchField === "name"
? "LIKE"
: "=";
const response = await this.servicenow.listUsers({
$,
params: {
sysparm_query: `${this.searchField}${operator}${this.searchValue}`,
sysparm_limit: this.limit,
},
});

const users = Array.isArray(response)
? response
: [];
$.export("$summary", `Found ${users.length} user(s) matching ${this.searchField} "${this.searchValue}"`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import servicenow from "../../servicenow.app.mjs";

export default {
key: "servicenow-get-catalog-item-variables",
name: "Get Catalog Item Variables",
description: "Retrieve the ordered variables (form fields) for a ServiceNow catalog item. Run **Search Catalog Items** first to obtain the item `sys_id`, then use the returned variable names to build the `variables` payload for **Add Item to Cart**, **Order Catalog Item**, or **Submit Record Producer**. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
props: {
servicenow,
catalogItemSysId: {
propDefinition: [
servicenow,
"catalogItemSysId",
],
},
},
async run({ $ }) {
const response = await this.servicenow.getCatalogItemVariables({
$,
catalogItemSysId: this.catalogItemSysId,
});

const variables = Array.isArray(response)
? response
: (response?.variables ?? []);
$.export("$summary", `Successfully retrieved ${variables.length} variable(s) for catalog item ${this.catalogItemSysId}`);

return variables;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "servicenow-get-current-user",
name: "Get Current User",
description: "Returns the authenticated ServiceNow user's sys_id, name, email, username, and instance URL. Call this first when the user says 'my incidents', 'my cases', 'assigned to me', or needs their ServiceNow identity. Use `sys_id` to filter records in **Get Table Records** (e.g. `assigned_to={sys_id}`) or **Create Table Record**. [See the documentation](https://docs.servicenow.com/bundle/vancouver-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html).",
version: "0.0.2",
version: "0.0.3",
type: "action",
annotations: {
destructiveHint: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
key: "servicenow-get-record-counts-by-field",
name: "Get Record Counts by Field",
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)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -38,7 +38,7 @@
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`)",
optional: true,
},
aggregateInfo: {

Check warning on line 41 in components/servicenow/actions/get-record-counts-by-field/get-record-counts-by-field.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop aggregateInfo must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 41 in components/servicenow/actions/get-record-counts-by-field/get-record-counts-by-field.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop aggregateInfo must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "servicenow-get-table-record-by-id",
name: "Get Table Record by ID",
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)",
version: "1.0.3",
version: "1.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
key: "servicenow-get-table-records",
name: "Get Table Records",
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)",
version: "1.0.3",
version: "1.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -20,7 +20,7 @@
"table",
],
},
filterInfo: {

Check warning on line 23 in components/servicenow/actions/get-table-records/get-table-records.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop filterInfo must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 23 in components/servicenow/actions/get-table-records/get-table-records.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop filterInfo must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "You must provide either a `Query` or at least one `Filter` prop. ",
Expand Down
2 changes: 1 addition & 1 deletion components/servicenow/actions/list-tables/list-tables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "servicenow-list-tables",
name: "List Tables",
description: "List all tables in the ServiceNow instance. [See the documentation](https://www.servicenow.com/docs/r/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.2",
version: "0.0.3",
type: "action",
annotations: {
destructiveHint: false,
Expand Down
Loading
Loading