BLOG - ServiceNow CartJS : Automate Laptop Requests
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Use Case:
When a new employee joins the organization, the IT department need to provide them with a laptop. Instead of doing this manually each time —the IT member should navigate to the Service Catalog, select the laptop item, fill in the details, and submit the request.
But what if ServiceNow could do this automatically the moment a new user is created?
In this article, I’ll walk u through how to automate laptop provisioning using:
A Business Rule
A Script Include
The sn_sc.CartJS() API
🎯 Use Case Overview
Use Case:
Whenever a new employee joins the organization, ServiceNow should automatically create a laptop request for them.
This ensures:
No onboarding delays
No manual catalog submissions
No missed hardware provisioning
🔑 Key Points of the Automation
1. Fully Automated Laptop Provisioning
As soon as a new user record is created (e.g., by HR ), ServiceNow automatically submits a laptop request on their behalf.
2. Uses the CartJS API
CartJS lets developers interact with the Service Catalog programmatically — adding items, setting variable values, and checking out the cart.
3. Script Include Handles the Cart Operations
The entire catalog logic (add item → set variables → checkout) is written once and reused.
4.Business Rule Detects User Creation
When a user is inserted, the Business Rule triggers the Script Include to start the provisioning workflow.
Understanding the sn_sc.CartJS() API
In ServiceNow, sn_sc.CartJS() is a powerful API that helps automate the management of catalog items within the Service Catalog.
Normally, users manually pick an item, fill in variables, and submit the request. With CartJS, all of this can be automated.
What CartJS Can Do
Add catalog items to the cart
Set variable values
Submit (checkout) the cart
Automatically generate:
REQ – Request
RITM – Request Item
CTASK – Catalog Tasks
🚀 Why CartJS Is Important
✔ Automating Catalog Item Creation
Perfect for use cases like onboarding, where items need to be requested automatically without user input.
✔ Pre-Filling Catalog Variables
Variables can be dynamically populated based on user data, roles, department, or custom logic.
✔ Integrating Complex Workflows
CartJS simplifies integration with processes like:
Asset Management
HR Onboarding
Incident Management
Approval Workflows
Using CartJS ensures accuracy, saves time, and reduces human error.
Script Include: LaptopProvisioningCart
This Script Include contains the logic for adding the laptop item to the cart and checking it out.
What It Does
Loads the user
Creates a CartJS instance
Defines the laptop catalog item
Sets software variables automatically
Adds the item to the cart
Submits the cart (checkout)
Returns the created REQ number
Business Rule: Automatically Create Laptop Request
This Business Rule contains the logic for Automatically Create Laptop Request for New Users
What it Does
Detect new user creation
Call the Script Include
Fetch the request number (REQ)
Display confirmation
Automation Result :
- Labels:
-
Request Management
-
Service Catalog
