Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Expand Up @@ -5,7 +5,7 @@ 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.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "servicenow-checkout-order-guide",
name: "Checkout Order Guide",
description: "Checkout a ServiceNow order guide using the items returned by **Submit Order Guide**. Pass those items as-is — this action maps `quantity` to `sysparm_quantity` and array `variables` (including nested `children`) to an object. Fill unanswered mandatory item variables in `items` first, and omit optional blank ones. If the order guide's Two step flag is on, this submits the order and returns the REQ number and `sys_id`. If the flag is off, items are added to the user's default cart and no REQ is returned — review with **View Cart**, then call **Submit Cart Order**. Use **Check Order Status** after a REQ exists. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.1",
version: "0.0.2",
type: "action",
ai: "optimized",
annotations: {
Expand Down
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.6",
version: "1.0.7",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
Expand Down
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.7",
version: "0.0.8",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/servicenow/actions/empty-cart/empty-cart.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
Expand Down
2 changes: 1 addition & 1 deletion components/servicenow/actions/find-users/find-users.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "servicenow-get-article-attachment",
name: "Get Article Attachment",
description: "Download an attachment from a knowledge article to the `/tmp` directory. Run **Get Article** first: its `attachments` array holds each attachment's `sys_id` and `file_name`, but only when the article record has `display_attachments` enabled. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/knowledge-api.html)",
version: "0.0.3",
version: "0.0.4",
type: "action",
ai: "optimized",
annotations: {
Expand Down
2 changes: 1 addition & 1 deletion components/servicenow/actions/get-article/get-article.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "servicenow-get-article",
name: "Get Article",
description: "Retrieve a single knowledge article, including its entire HTML body (`content`). Run **Search Knowledge Base** first to find an article, then pass its `number` or `sys_id` here. The `attachments` array is only returned when the article record has `display_attachments` enabled. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/knowledge-api.html)",
version: "0.0.3",
version: "0.0.4",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import servicenow from "../../servicenow.app.mjs";
import { describeCatalogVariables } from "../../common/utils.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.5",
description: "Retrieve the ordered variables (form fields) for a ServiceNow catalog item or record producer, with where each field's valid values come from. Run **Search Catalog Items** first to obtain the item `sys_id`, then use the returned variable `name`s to build the `variables` payload for **Add Item to Cart**, **Order Catalog Item**, or **Submit Record Producer**, and fill every variable with `mandatory: true`. Each choice-based variable has an `options` object: when `options.source` is `choices`, pick a `value` from the inline `choices` (lookup choices are already filtered by ServiceNow for the signed-in user); when it is `table`, run **Get Table Records** on `options.table` with `options.query` (if present) plus the user's search text and submit the record `sys_id`. `options.qualifier_unresolved: true` means the form filters this field with a script that cannot be evaluated here, so confirm the choice with the user; `options.depends_on` lists variables whose values change the valid options. Script defaults such as the current user are resolved into `value`, with the original script in `default_script`. Use **Get Catalog Item** for item details such as price and category. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.6",
type: "action",
ai: "optimized",
annotations: {
Expand All @@ -21,15 +22,52 @@ export default {
],
},
},
methods: {
async resolveScriptDefault($, variable, cache) {
const script = variable.default_script.trim();
if (script.includes("^")) {
return "";
}
const key = `${variable.reference}|${script}`;
if (!cache.has(key)) {
cache.set(key, this.servicenow.getTableRecords({
$,
table: variable.reference,
params: {
sysparm_query: `sys_id=${script}`,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
sysparm_fields: "sys_id",
sysparm_limit: 2,
},
}).then((records) => (Array.isArray(records) && records.length === 1
? records[0].sys_id
: ""))
.catch(() => ""));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
return cache.get(key);
},
},
async run({ $ }) {
const response = await this.servicenow.getCatalogItemVariables({
$,
catalogItemSysId: this.catalogItemSysId,
});

const variables = Array.isArray(response)
const {
variables, scriptDefaults,
} = describeCatalogVariables(Array.isArray(response)
? response
: (response?.variables ?? []);
: (response?.variables ?? []));

const cache = new Map();
await Promise.all(scriptDefaults.map(async (variable) => {
const sysId = await this.resolveScriptDefault($, variable, cache);
if (sysId) {
variable.value = sysId;
} else {
variable.default_unresolved = true;
}
}));

$.export("$summary", `Successfully retrieved ${variables.length} variable(s) for catalog item ${this.catalogItemSysId}`);

return variables;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ConfigurationError } from "@pipedream/platform";
import servicenow from "../../servicenow.app.mjs";

export default {
key: "servicenow-get-catalog-item",
name: "Get Catalog Item",
description: "Retrieve details for a ServiceNow catalog item or record producer: name, short and full description, price and recurring price, catalogs and categories, item type, whether an attachment is mandatory, and its catalog UI policies and client scripts. Run **Search Catalog Items** first to obtain the item `sys_id`. To build the `variables` payload for **Add Item to Cart**, **Order Catalog Item**, or **Submit Record Producer**, use **Get Catalog Item Variables**, which returns each form field with its valid options. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.0.1",
type: "action",
ai: "optimized",
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
props: {
servicenow,
catalogItemSysId: {
propDefinition: [
servicenow,
"catalogItemSysId",
],
},
includeVariables: {
type: "boolean",
label: "Include Variables",
description: "Set to `true` to also return the raw `variables` array. Leave unset to omit it; **Get Catalog Item Variables** returns the same fields with option guidance.",
optional: true,
default: false,
},
},
async run({ $ }) {
let item;
try {
item = await this.servicenow.getCatalogItem({
$,
catalogItemSysId: this.catalogItemSysId,
});
} catch (error) {
if (error?.response?.status === 500) {
throw new ConfigurationError(`ServiceNow could not load the details of catalog item \`${this.catalogItemSysId}\` (HTTP 500). This happens for some record producers; run **Get Catalog Item Variables** to get its form fields.`);
}
throw error;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

const result = {
...item,
};
if (!this.includeVariables) {
result.variable_count = Array.isArray(item?.variables)
? item.variables.length
: 0;
delete result.variables;
}

$.export("$summary", `Successfully retrieved catalog item ${result.name ?? this.catalogItemSysId}`);

return result;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
key: "servicenow-get-catalog-ui-policies",
name: "Get Catalog UI Policies",
description: "Retrieve catalog UI policy actions for a ServiceNow catalog item from `catalog_ui_policy_action` (visibility, mandatory, and read-only rules). Each action includes its parent `catalog_ui_policy` record, including `catalog_conditions`. Run **Search Catalog Items** first to obtain the item `sys_id`. Use with **Get Catalog Item Variables** when building a form, then **Add Item to Cart** or **Checkout Order Guide**. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.1",
version: "0.0.2",
type: "action",
ai: "optimized",
annotations: {
Expand Down
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.6",
version: "0.0.7",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "servicenow-get-incident",
name: "Get Incident",
description: "Retrieve a ServiceNow incident from the `incident` table by number. Use this after **Submit Record Producer** or **Create Table Record** when you need the incident state, priority, and assignment for a follow-up link. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.1",
version: "0.0.2",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { assertSafeQueryValue } from "../../common/utils.mjs";
export default {
key: "servicenow-get-question-choices",
name: "Get Question Choices",
description: "Retrieve select-box choices for a ServiceNow catalog variable from the `question_choice` table. Run **Get Catalog Item Variables** first and pass the variable `sys_id` (or `id`). For table-backed reference variables, use **Get Table Records** on the variable's lookup table instead. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.1",
description: "Retrieve select-box choices for a ServiceNow catalog variable from the `question_choice` table, including inactive-filtered ordering. Prefer the inline `choices` from **Get Catalog Item Variables**: reading `question_choice` usually requires a catalog admin role, so most signed-in employees get a 403 here. Pass the variable `sys_id` (or `id`) from **Get Catalog Item Variables**. For table-backed reference variables, use **Get Table Records** on the variable's `options.table` instead. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.2",
type: "action",
ai: "optimized",
annotations: {
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.7",
version: "0.0.8",
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 @@ -6,7 +6,7 @@ export default {
key: "servicenow-get-requested-items",
name: "Get Requested Items",
description: "Retrieve requested items (RITMs) from the `sc_req_item` table for a catalog request. Provide the request number returned by **Checkout Cart**, **Submit Cart Order**, **Order Catalog Item**, or **Checkout Order Guide**. Use this after checkout to get RITM numbers and states for follow-up links. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.1",
version: "0.0.2",
type: "action",
ai: "optimized",
annotations: {
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.6",
version: "1.0.7",
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.6",
version: "1.0.7",
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "servicenow-list-knowledge-bases",
name: "List Knowledge Bases",
description: "List the knowledge bases in the instance, to find the `sys_id`s that scope a search on **Search Knowledge Base**. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_TableAPI.html)",
version: "0.0.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
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.5",
version: "0.0.6",
type: "action",
annotations: {
destructiveHint: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "servicenow-order-catalog-item",
name: "Order Catalog Item",
description: "Place a one-step Order Now request for a single ServiceNow catalog item, bypassing the cart. Run **Search Catalog Items** to find the item `sys_id` and **Get Catalog Item Variables** to learn which variable names to supply. 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.4",
version: "0.0.5",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "servicenow-search-catalog-items",
name: "Search Catalog Items",
description: "Search the ServiceNow Service Catalog for orderable items. Use this first to discover catalog item `sys_id` values needed by **Get Catalog Item Variables**, **Add Item to Cart**, **Order Catalog Item**, **Submit Record Producer**, and **Submit Order Guide**. Set **Item Type** to `Order Guide` to find order guides. [See the documentation](https://www.servicenow.com/docs/r/zurich/api-reference/rest-apis/c_ServiceCatalogAPI.html)",
version: "0.1.0",
version: "0.1.1",
type: "action",
ai: "optimized",
annotations: {
Expand Down
Loading
Loading