Save and Load Template Feature for ServiceNow Catalog Items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
While requesting Service Catalog items, users often face a common problem: too many variables (fields) on the catalog form.
In real-life scenarios—especially during emergencies—users do not have enough time to fill all these fields again and again. This leads to frustration and delays.
In record forms, ServiceNow provides a Template option to quickly populate fields. However, Service Catalog items do not have a built-in option for users to save and reuse their own templates.
To solve this gap, I implemented a custom solution that allows end users to save and load templates directly on the catalog item form. I am not sure if this already exists as an OOTB feature, but this is my own approach for this use case.
What This Solution Does
This solution adds two options on the Service Catalog item form:
- Save Template
- Load Template
These options allow users to quickly reuse previously filled values for the same catalog item
Save Template – How It Works
When a user clicks Save Template:
- A popup opens asking for:
- Template Name
- Description
- Scope:
- User Scope – template visible only to the current user
- Global Scope – template visible to all users
- Once saved:
- All catalog variables and their values are captured
- The template is stored for future use
Load Template – How It Works
When a user clicks Load Template:
- The system shows a list of:
- User-specific templates
- Global templates
- After selecting a template and clicking Apply:
- All matching variables are auto-filled on the catalog form
- This saves time and avoids repetitive data entry
Technical Implementation Overview:
- Widget
- I created a custom widget
- This widget is displayed on the catalog item form using a custom catalog variable
2) Widget Logic
- The widget uses a timeout function to wait until the full catalog form is loaded
- Until g_form is ready:
- Save Template and Load Template buttons are disabled
- Once g_form is initialized:
- The widget enables user actions
- g_form.getValue() and g_form.setValue() are used
saving the Template (Client → Server)
- On Save Template click:
- An empty JavaScript object is created
- Using g_form.getEditableFields(), all variable names and values are collected
- This object is sent to the server
Storage Logic
- Templates are stored in the sys_user_preference table
- Fields used:
- Key:
catalog_item_sys_id + "_" + template_name (ensures uniqueness) - User:
- Empty → Global template
- Current user → User-specific template
- Value:
- Variable object converted to string (JSON)
Loading the Template
- On Load Template click:
- Query sys_user_preference table where:
- Key starts with catalog item sys_id
- User is current user OR empty (global)
- The selected template value is:
- Parsed back into an object
- Matched with catalog variable names
- Values are populated using g_form.setValue()
Benefits of This Approach
- Reduces time to raise catalog requests
- Improves user experience
- Helpful during emergency or repetitive requests
- Supports both personal and shared (global) templates
- No impact on existing catalog functionality
I would love to hear from the community:
- Is there any OOTB feature or plugin that already supports saving and loading templates for Service Catalog items?
- Has anyone already implemented a similar solution? If yes, please share your approach or experience.
- Any suggestions or improvements to make this solution better or more scalable?
If you find this solution or implementation useful, please consider marking this post as Helpful
The code for this solution is quite lengthy, so I am not able to share it directly here.
If anyone is interested in reviewing the code or discussing the implementation in detail, please feel free to reach out to me:
Email: adhalraotejas1018@gmail.com
LinkedIn: https://www.linkedin.com/in/tejas1018
I’ll be happy to connect and share more details.
Thanks!
aslo check my approval page design : https://www.servicenow.com/community/developer-forum/redesigned-my-approvals-page-with-bulk-approve-...
load template clicked :
save tempalte code :
c.saveTemplate = function() {
var values = {};
g_form.getEditableFields().forEach(function(name) {
// Collect values only for editable fields
values[name] = g_form.getValue(name);
});
spUtil.addInfoMessage("Saving template. Fields to save: " + Object.keys(values).length);
console.log("Template Values being sent to server:", values);
$scope.server.get({
action: 'save_pref',
templateName: c.templateName,
description: c.description,
scope: c.scope,
cat_item_sys_id: $scope.itemSysId,
values: values
}).then(function(response) {
spUtil.addInfoMessage("Template '" + c.templateName + "' saved successfully.");
c.closeModal();
// Clear form for next use
c.description = '';
c.scope = 'personal';
}).catch(function(err) {
spUtil.addErrorMessage( Failed to save template. Check server logs.");
});
};
- 114 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
15 hours ago
Why post this 2 times in the same topic?
https://www.servicenow.com/community/developer-forum/save-and-load-template-feature-for-servicenow-c...
https://www.servicenow.com/community/developer-forum/saving-amp-amp-loading-templates-for-service-ca...
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
