Umm Salama bint Abu Umaya reported,

The Messenger of Allah ﷺ said, "When you are present with a sick person or one who is dying, speak well, for the angels say amen to whatever you say."She said, when Abu Salama died, I went to the Prophet ﷺ and said, "Messenger of Allah, Abu Salama has died."He said, "Say, 'O Allah, forgive me and forgive him, and grant me a good successor in his place.'"She said, so I said it, and Allah granted me one who was better for me than him, Muhammad ﷺ.

Azami 11101

Sahih

عن أم سلمة قالت

قال رسول الله ﷺ: إذا حضرتم المريض أو الميت فقولوا خيرا، فإن الملائكة يؤمنون على ما تقولون، قالت: فلما مات أبو سلمة أتيت النبي ﷺ فقلت: يا رسول الله إن أبا سلمة قد مات، قال: قولي اللهم اغفر لي وله، واعقبني منه عقبى حسنة قالت: فقلت، فأعقبني الله من هو خير لي منه، محمدا ﷺ.

الأعظمي 11101صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Supplications, remembrances, and prayer upon the chosen Prophet ﷺ
Chapter
Supplications for illness and funerals, and what relates to them
Section
What is said upon affliction
Numbering
Jami al-Kamil 11101 (2nd edition)
Azami 11101