Help with relationship between tasks and Projects and Project Tasks

matthew_magee1
Giga Guru

I created two new fields on my task table: Related Project and Related Project Task

Our managers can add a related project to an SRQ, PRB, etc

Same for a related task (which doesn't have to be under the same project)

I created a new relationship called 'Tickets related to this project'

I'd like to do the following:

  1. show tasks where project == parent
  2. show tasks where the project task parent == parent

Here is my relationship so far. Pulling in #1 above is easy, it's the 2nd one that is causing me angst:

capture.jpg

Any help is greatly appreciated

1 REPLY 1

matthew_magee1
Giga Guru

Figured this out w/ a lot of trial and tribulation



Applies to table: Project


Queries from table: Task



Query with:



//query task table and get records where the related project (u_related_project) == opened project


var query = current.addQuery('u_related_project',parent.sys_id);


var ids = [];



//query pm_project_task table and get records where the project task parent = opened project


var pmtask = new GlideRecord('pm_project_task');


pmtask.addQuery('parent', parent.sys_id);


pmtask.query();



while (pmtask.next()) {


//spit out unique sysids of records in pm_project_task table


//gs.log('unique value: ' + pmtask.getUniqueValue());


//take sys id of project task and use it against the task table


var getTask = new GlideRecord('task');


//find any records where the sysid from the pm_project_task table matches the sysid of the task in the record u_related_project_task


getTask.addQuery('u_related_project_task',pmtask.getUniqueValue());


getTask.query();


ids = [];


while (getTask.next())


//if a record returns, push the task sysid to the ids array


ids.push(getTask.sys_id.toString());


//gs.log('ids: ' + ids);


query.addOrCondition('sys_id', ids);


}