
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 11:16 AM
Hello! I need to display the Predecessor and Successor (from Dependencies) on each Project Task.
The idea is that the person looking at the Project Task will be able to easily see if that task has predecessors or successors.
I've created two new reference fields, 'Successor Task' (u_successor_task), and 'Predecessor Task' (u_predecessor_task).
Then I created a Business Rule to run After Insert, Update or Delete. It uses the following script, which I do not think is correctly finding the Predecessor and Successors from the Dependencies, and definitely isn't population my new fields.
(function executeRule(current, previous /*null when 'insert' or 'delete'*/) {
// Get the successor (current task) sys_id
var successorSysId = current.child.toString();
// Get the predecessor (dependent task) sys_id
var predecessorSysId = current.parent.toString();
// Update the Successor's 'Predecessor Task' field
var successor = new GlideRecord('pm_project_task');
if (successor.get(successorSysId)) {
successor.setValue('u_predecessor_task', predecessorSysId);
successor.update();
}
// Update the Predecessor's 'Successor Task' field, if applicable
var predecessor = new GlideRecord('pm_project_task');
if (predecessor.get(predecessorSysId)) {
predecessor.setValue('u_successor_task', successorSysId);
predecessor.update();
}
})();
Does anyone have a solution for this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 03:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 04:04 PM
good to know, always choose the simple and viable approach.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution