I knew I could to this by Marking the records where the job was blocked and then showing only Marked records. This is the Gotcha: the default parameter for the Mark and MarkedOnly functions is false meaning it will effectively not do anything. The online help tells you this but still it’s a bit of a puzzler if you don’t do these things very often.
My code for Only Records with Blocked Jobs is as follows:
CLEARMARKS;
IF Rec.FINDSET THEN
REPEAT
IF "Job No." <> '' THEN BEGIN
lJob.GET("Job No.");
IF lJob.Blocked <> lJob.Blocked::" " THEN BEGIN
lBlockedJobsFound := TRUE;
Rec.MARK(TRUE);
END;
END;
UNTIL Rec.NEXT = 0;
IF lBlockedJobsFound THEN
MARKEDONLY(TRUE)
ELSE BEGIN
MARKEDONLY(FALSE);
MESSAGE('No blocked jobs found in this journal batch.');
END;
My code for showing all records is as follows:
CLEARMARKS;
MARKEDONLY(FALSE);
Still, it would be nice if the end-user could have applied this filter as they would be able to in Microsoft CRM. Maybe one day future versions of NAV will allow the user to define filters using related tables too.