Regarding Catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-04-2023 03:17 AM - edited ā10-04-2023 03:18 AM
How can i Create SCcatalog tasks based on the Catalog Item variables. For Example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-04-2023 04:19 AM
Hi @Ravichandra2 ,
To create Service Catalog (SC) catalog tasks based on Catalog Item variables and conditions, you can use Catalog Client Scripts in ServiceNow. These scripts allow you to dynamically generate and configure catalog tasks based on the user's selections and conditions.
Here's an example script based on your requirements:
// Get the selected request type and variables
var requestType = g_form.getValue('request_type');
var ram = parseFloat(g_form.getValue('ram'));
var disk = parseFloat(g_form.getValue('disk'));
var cpu = parseFloat(g_form.getValue('cpu'));
// Define the catalog task assignment group
var assignmentGroup = '';
// Check the request type and variables to determine the assignment group
if (requestType == 'New VDI') {
assignmentGroup = 'AMER ITSD'; // Set the assignment group for New VDI
} else if (requestType == 'Configuration Change' && ram <= 16 && disk <= 120 && cpu <= 3) {
assignmentGroup = 'Endpoint Engineering'; // Set the assignment group for Configuration Change
}
// Create the catalog task if an assignment group is specified
if (assignmentGroup) {
var catalogTask = new GlideRecord('sc_task');
catalogTask.initialize();
catalogTask.cat_item = current.sys_id; // Set the catalog item reference
catalogTask.assignment_group.setDisplayValue(assignmentGroup); // Set the assignment group
catalogTask.insert();
}
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-04-2023 04:48 AM
Thank You very much @Ratnakar7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-04-2023 06:30 AM
HI @Ravichandra2 ,
I trust you are ding great.
Please find below script for the same.
(function executeRule(current, previous /*null when async*/) {
// Function to create a catalog task
function createCatalogTask(assignmentGroup, shortDescription) {
var task = new GlideRecord('sc_task');
task.initialize();
task.short_description = shortDescription;
task.assignment_group.setDisplayValue(assignmentGroup);
task.request_item = current.sys_id;
task.insert();
}
// Check for New VDI request type
if (current.variables.request_type == 'New VDI') {
createCatalogTask('AMER ITSD', 'Task for New VDI request');
}
// Check for Configuration Change request type with conditions
else if (current
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-04-2023 07:27 AM
I am completed some steps using flow designer but some thing for values i am not able to give the conditions like less than and greater than on it
Thanks and Regards
ravichandra