How to create a child catalog task from Catalog Task via workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
How to create a child catalog task from a catalog task via workflow. When a subcategory of a primary catalog task is changed to L2, it should close the current task and create a new child catalog task to the primary catalog task. How do I achieve this?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Based on the workflow diagram you provided, your structural logic is already in the right place! You have the first task (pink), followed by an If condition (green), which then routes to the second task (blue).
However, there is a fundamental rule about how ServiceNow workflows operate: a workflow pauses at a Catalog Task activity and will not move to the next activity (your If condition) until that task is closed.
To achieve your goal where changing the subcategory to "L2" immediately closes the task and triggers the next one, you need a combination of a Business Rule and your existing Workflow.
Here is how to set this up:
Step 1: Create a Business Rule to Auto-Close the First Task
Since the workflow is waiting for the task to close, you need a Business Rule on the Catalog Task (sc_task) table to automatically close it as soon as the subcategory is changed to L2.
Navigate to System Definition > Business Rules.
Click New.
Set the following parameters:
Name: Auto-Close L2 Tasks
Table: Catalog Task [sc_task]
When: Before
Update: True (Checked)
Under the Filter Conditions tab:
Subcategory | changes to | L2
(Note: If Subcategory is a catalog variable rather than a task field, select Item Option: Subcategory instead).
Under the Actions tab:
Set State | To | Closed Complete (or whichever closed state you prefer).
Result: When the fulfiller changes the subcategory to L2 and saves, the task automatically closes. This tells the workflow to wake up and move to the next step.
Step 2: Configure Your If Condition (Green Circle)
Now that the first task is closed, the workflow moves to your If activity. You need to configure this to check if the L2 condition was met.
Depending on where "Subcategory" lives, configure the condition:
If Subcategory is a Catalog Variable: You can usually just use the condition builder inside the If activity to check Variables > [Your Catalog Item] > Subcategory = L2.
If using a Script inside the If activity:
answer = ifScript();
function ifScript() {
// Assuming 'subcategory' is a variable on the RITM
if (current.variables.subcategory == 'L2') {
return 'yes';
}
return 'no';
}
Step 3: Configure the Second Catalog Task (Blue Circle)
If the If condition evaluates to "Yes", it hits your second Catalog Task activity ("Task for ops team").
RITM Attachment: By default, dragging a Catalog Task activity onto the canvas automatically attaches this new task to the same parent Requested Item (RITM) as the first task.
Making it a literal "Child" of the first task: Normally, sequential catalog tasks are just siblings under the same RITM. If you strictly need the new task to have its parent field populated with the sys_id of the first task (pink circle), you need to pass that sys_id.
In the first task (pink), add this to the advanced script: workflow.scratchpad.first_task_id = task.sys_id;
In the second task (blue), add this to the advanced script: task.parent = workflow.scratchpad.first_task_id;
Once this is set up, changing the subcategory on the active task will trigger the Business Rule to close it, which advances the workflow through the If gate and instantly generates your new L2 Ops task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @The Matrix ,
Could you please provide a bit more detail on where you're currently stuck?
Specifically
- Have you already implemented the logic to detect when the subcategory changes to L2?
- Could you clarify when you want the system to evaluate the subcategory change? Should it monitor the Catalog Task and create the child task immediately when the subcategory changes to L2, or should it check after 1 day and then create the child task if the subcategory is L2
- Are you facing issues with creating the child Catalog Task, relating it to the parent task, or closing the current task?
A brief overview of your current implementation and the specific challenge you're encountering would help the community provide more targeted guidance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @rahulkoheda Yes, I have already implemented the logic for subcategory changes to L2 and creating new catalog task using catalog Task activity, but the requirement is to create a child task on a originally created task not a seperate task on RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Using Run script ,
- Close the existing SC_task
- Create the SCTASK using script. ,
- Assign it to proper assignment group
- Add duration ,so that task_sla gets generated for the task.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti