doGetRelatedRecords in library and testcode for it