Finally fixed the problem with entityreference