Numerous δ Sct and γ Dor pulsators are identified in the region of the Hertzsprung-Russell diagram that is occupied by chemically peculiar magnetic Ap stars. The connection between δ Sct and γ Dor pulsations and the magnetic field in Ap stars is however not clear: theory suggests for magnetic Ap stars some critical field strengths for pulsation mode suppression by computing the magnetic damping effect for selected p and g modes. To test these theoretical considerations, we obtained PEPSI spectropolarimetric snapshots of the typical Ap star HD 340577, for which δ Sct- like pulsations were recently detected in TESS data, and the γ Dor pulsator HR 8799, which is a remarkable system with multiple planets and two debris disks. Our measurements reveal the presence of a magnetic field with a strength of several hundred Gauss in HD 340577. The measured mean longitudinal field would be the strongest field measured so far in a δ Sct star if the pulsational character of HD 340577 is confirmed spectroscopically. No magnetic field is detected in HR 8799.