Sayyiduna Abdullah bin Umar (may Allah be pleased with them both) narrates that the Prophet (peace and blessings be upon him) said: "Whoever sees a person afflicted (with a trial, hardship or illness) and recites this supplication: 'Al-hamdu lillahil-ladhi 'afani mimmabtalaka bih, wa faddalani 'ala kathirin mimman khalaqa tafdila'
(All praise belongs to Allah, who has kept me safe from what He has afflicted you with, and who has greatly favoured me over much of His creation.)
The Prophet (peace and blessings be upon him) says: that trial will not befall that person."
Al-Tabarani recorded it in al-Mu'jam al-Awsat; its chain contains a narrator, Zakariyya bin Yahya bin Ayyub al-Darir, whom I do not know, and the remaining narrators of this report are thiqat (trustworthy).
Hadith Referenceمجمع الزوائد ومنبع الفوائد / كتاب الأذكار / 17139