Magnetic fields in active galactic nuclei and microquasars