- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 09:04 AM
Can anyone provide information on how I would create a catalog task when a catalog item variable is selected? We do not want to modify our workflow.
Ex: Currently, if a customer requests hardware and selects it is a replacement, two tasks are generated. One is assigned to a group to allocate and assign the hardware and the other task is assigned to a group to configure and deliver. We would like a 3rd task to be generated to collect the old hardware if replacement is selected.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2016 12:23 PM
Below is a business rule to create a Catalog Task when the associate selects the Replacement option on the Desktop or Laptop catalog item. The task is not created until after the request is approved. It also puts the computer name they are replacing (variable "computer_to_replace") into the short description and assigns the task to the Asset Management group.
Business Rule...
Name: Create Task - Replacement Hardware
Table: Requested Item [sc_req_item]
Active: true
Advanced: true
WHEN TO RUN.....
When: After
Order: 100
Insert: true
Update: true
Conditions: Item IS Laptop Computer -OR- Desktop Computer -AND- Request.Approval IS Approved
ADVANCED.....
Condition: blank
Script:
function onAfter (current,previous) {
//This function will be automatically called when this rule is processed.
createTasks();
// Start creating the Task to Collect IT Equipment
function createTasks() {
// Verify the Replacement option is chosen in the catalog item
var replace = current.variables.replacement;
// Get the computer name from the variable
var computer = current.variables.computer_to_replace;
// If it is a Replacement, go to the Catalog Task table [sc_task] and create the Task with this information.
if (replace == 'Replacement') {
var newtask1 = new GlideRecord('sc_task');
newtask1.initialize();
// Line below binds the RITM to the Task being created.
newtask1.request_item = current.sys_id;
newtask1.short_description = 'Collect old IT equipment - ' + computer;
newtask1.assignment_group = '8b61cf5f0a0a3c44007e37077628e90f'; // Asset Management : SYSID from Groups module
newtask1.insert();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 09:06 AM
Consuelo,
You need to modify the Workflow if the 2 tasks which are being generated are done through workflow so that everything is managed from Workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 09:23 AM
Hello Consuelo:
Why don't you create your first task as collect the old hardware if replacement is selected and then follow with the other two tasks outlined. This way workflow will be smoother. Hope this is helpful.
Cheers
Danny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 09:29 AM
Thank Mani for your reply:) We currently have a workflow which is used across several catalog items and wanted to avoid updating the workflow simply to create one extra task on this one catalog item. We are looking for an alternative to changing the workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 09:48 AM
Hi,
In this case, copy your workflow and modify it with the required changes and attached it with your catalog item.
By doing that, your other catalog items will not be impacted and you will have new individual work flow for this catalog item.