Skip to content

Commit

Permalink
Add a guard method around the scan for related WI incase there are no…
Browse files Browse the repository at this point in the history
…ne (#2004)

fixes #2003
  • Loading branch information
rfennell authored Oct 23, 2024
1 parent 1290835 commit 8d4dee7
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -800,17 +800,19 @@ export async function getAllDirectRelatedWorkitems (
var wi = workItems[wiIndex];

agentApi.logInfo(`Looking for parents and children of WI [${wi.id}]`);
for (let relIndex = 0; relIndex < wi.relations.length; relIndex++) {
var relation = wi.relations[relIndex];
if ((relation.attributes.name === "Child") ||
(relation.attributes.name === "Parent")) {
var urlParts = relation.url.split("/");
var id = parseInt(urlParts[urlParts.length - 1]);
if (!relatedWorkItems.find(element => element.hasOwnProperty("id") && element.id === id)) {
agentApi.logInfo(`Add ${relation.attributes.name} WI ${id}`);
relatedWorkItems.push(await (workItemTrackingApi.getWorkItem(id, null, null, WorkItemExpand.All, null)));
} else {
agentApi.logInfo(`Skipping ${id} as already in the relations list`);
if (wi.relations) {
for (let relIndex = 0; relIndex < wi.relations.length; relIndex++) {
var relation = wi.relations[relIndex];
if ((relation.attributes.name === "Child") ||
(relation.attributes.name === "Parent")) {
var urlParts = relation.url.split("/");
var id = parseInt(urlParts[urlParts.length - 1]);
if (!relatedWorkItems.find(element => element.hasOwnProperty("id") && element.id === id)) {
agentApi.logInfo(`Add ${relation.attributes.name} WI ${id}`);
relatedWorkItems.push(await (workItemTrackingApi.getWorkItem(id, null, null, WorkItemExpand.All, null)));
} else {
agentApi.logInfo(`Skipping ${id} as already in the relations list`);
}
}
}
}
Expand Down

0 comments on commit 8d4dee7

Please sign in to comment.