Hi Marvin
Some background first. When you create a follow-up work order the work order from which you generated the follow-up goes into the Originating Record field of the follow-up. Phew, now say that three times in a row and this is your first clue.
The user is of course taken to the follow-up work order to complete any information needed to get that bit of work done, You can, of course, go to the Related Records tab to see the immediate records upstream and downstream. This is stored in the RELATEDRECORD table. This is your second clue.
Also, the originating work order has the HASFOLLOWUPWORK flag enabled. Beware as this is not quite correct if you're only looking for follow-up work orders, The HASFOLLOWUPWORK field means
any follow-up. This could be an SR, work order, incident, change, release, problem, MOC.... It all depends on what industry solution you're using, but their all some sort of follow-up.
So, I've created a little SQL statement that shows the count of RELATEDRECORDs that are only work order based and are a follow-up from the work order you're enquiring from.
SELECT wonum, w.HASFOLLOWUPWORK ,(SELECT count(*) FROM RELATEDRECORD r WHERE RECORDKEY = w.wonum AND r.SITEID = w.siteid AND RELATEDRECCLASS= 'WORKORDER' AND RELATETYPE= 'FOLLOWUP')
FROM workorder w where problemcode = 'LEAK';
or maybe
SELECT wonum, w.HASFOLLOWUPWORK ,
(SELECT count(*) FROM RELATEDRECORD r WHERE RECORDKEY = w.wonum AND r.SITEID = w.siteid AND RELATEDRECCLASS= 'WORKORDER' AND RELATETYPE= 'FOLLOWUP') AS c1
FROM workorder w
WHERE (SELECT count(*) FROM RELATEDRECORD r WHERE RECORDKEY = w.wonum AND r.SITEID = w.siteid AND RELATEDRECCLASS= 'WORKORDER' AND RELATETYPE= 'FOLLOWUP') >=1;
I hope that this gives you some insight and an idea for the query.