only add external metadata ref if IDs exist
Merge pull request #656 from teharrison/develop

only add external metadata ref if IDs exist