- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 12:53 PM
What query would I use for a Related List that applies to Project, that will show me all Change Requests where the top_task of the parent of the Change Request is the same as the parent.sys_id of the Project?
Basically I want every Change Request that has a Parent that is either the Project, or is one of the Project's children tasks. The thing that ties them all together is 'top_task'. The problem is, the parent of Change Request is referencing 'Task', which does not have top_task - so is this even possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 02:21 PM
Yes, that should be right. Applies to should be Project and Queries from should be Change Request. If I were to take an educated guess on this one, Id say the problem is on line 7. Try this:
var gr = new GlideRecord('planned_task'),
tasks = [parent.sys_id];
gr.addQuery('top_task', parent.sys_id + '');
gr.query();
while (gr.next()) {
tasks.push(gr.sys_id + '');
}
current.addQuery('parent', 'IN', tasks.join(','));
The plus quote forces the sys_id to a string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 01:32 PM
You should be able to use a Defined Related List where you pull a list of all project tasks where top_task is current.sys_id then apply that list to the change_request.parent. Example:
var gr = new GlideRecord('planned_task'),
tasks = [parent.sys_id];
gr.addQuery('top_task', parent.sys_id + '');
gr.query();
while (gr.next()) {
tasks.push(gr.sys_id);
}
current.addQuery('parent', 'IN', tasks.join(','));
You can of course change the planned_task to project_task if appropriate. But that is the gist, get all the project tasks and inject their sys_id's into the Defined Related List's query. I hope this helps.
Kind regards,
Travis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 01:53 PM
I changed planned_task to pm_project_task but it's not pulling the children tasks in, only where the Project is the Change Request parent.
I just needed to enter this under 'Query with:' under Relationships right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 02:21 PM
Yes, that should be right. Applies to should be Project and Queries from should be Change Request. If I were to take an educated guess on this one, Id say the problem is on line 7. Try this:
var gr = new GlideRecord('planned_task'),
tasks = [parent.sys_id];
gr.addQuery('top_task', parent.sys_id + '');
gr.query();
while (gr.next()) {
tasks.push(gr.sys_id + '');
}
current.addQuery('parent', 'IN', tasks.join(','));
The plus quote forces the sys_id to a string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 04:47 AM
It's working, thanks Travis!