Carry over 'priority' from Task to Task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 10:30 AM
I am trying to figure out how to carry over priority from task to task.
when 1st gets close completed with priority as High then that priority need to carry over to 2nd task and other task.
please help me achieve this.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 10:59 AM
You can use a business rule to achieve your requirement. However, you need to post how different tasks are related to get a more detailed response here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 11:03 AM - edited 10-09-2023 11:10 AM
Hi @prash4 ,
To carry over the priority from one task to another in ServiceNow, you can achieve this using Business Rules or Script Includes. Here's a step-by-step guide using Business Rules:
### Using Business Rules:
1. **Create a Business Rule:**
- Navigate to "System Definition" > "Business Rules" in the application navigator.
- Click on "New" to create a new Business Rule.
- Set the table to the task table (e.g., "incident" for Incident tasks).
- Choose the appropriate condition for when this rule should run. For example, you might want to run it when the task state is set to "Closed Complete."
- Configure the "Advanced" field to specify additional conditions if necessary.
2. **Define the Business Rule Script:**
- In the "Script" tab of the Business Rule, write a script that checks if the current task has a priority of "High."
- If the condition is met, loop through related tasks (if applicable, depending on your use case) and set their priority to "High" as well.
Example Business Rule Script:
(function executeRule(current, previous /*null when async*/) {
if (current.priority == 1 /* High */) {
// Query related tasks (change 'task_table' to the appropriate related task table)
var relatedTasks = new GlideRecord('task_table');
relatedTasks.addQuery('parent', current.sys_id); // Assuming there's a parent-child relationship
relatedTasks.query();
// Set priority to High for related tasks
while (relatedTasks.next()) {
relatedTasks.priority = 1; // 1 corresponds to High priority
relatedTasks.update();
}
}
})(current, previous);
In this script, `current.priority` is assumed to be `1` for "High" priority. Adjust the condition and table relationships based on your specific use case.
3. **Save and Test:**
- Save the Business Rule and test it by closing the first task with a priority of "High." Check if the priority is correctly carried over to related tasks.
### Note:
- Adjust the script according to your table relationships and field names.
- Always test the Business Rule in a non-production environment before deploying it to your live instance to avoid unintended consequences.
Remember to replace `'task_table'` with the actual name of the related task table, and adjust the conditions to match your specific requirements.
Mark my answer helpful & accepted if it helps you resolve your issue.
Thanks,
Danish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 11:31 AM
There are a lot of ways to go about this, as you can see above. Probably the easiest way, assuming each cat item has only 1 task at a time, is to create a business rule that triggers when the cat task is closed. When that happens update that cat tasks requested items priority to the same priority as the cat task when it is closed. Then us an on insert business rule to set the cat task priority to the same priority as the requested item when it is created.