We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to update image in message HTML in notification

t venkatesh2
Tera Contributor

Hi,

 I need to update image in notifications which is used in multiple notifications.

If I am trying to update below screen I can see.

tvenkatesh2_0-1768993250964.png

But, I found the image source is from images table, there I am updated the image so that it will update all places wherever it is used.
But, I don't see the changes in notifications, previous image only i can see.

Please suggest how to update image in message HTML in notification 

below is the sample.

tvenkatesh2_1-1768993798971.png

 

 

4 REPLIES 4

yashkamde
Mega Sage

Hello @t venkatesh2 ,
Actually the image you are trying to insert or any ootb images are configure in Email Templates table "sysevent_email_template" so you will need to create a custom template like the image and input the data you required

Screenshot 2026-01-21 165536.png

 

This will results in this type of preview notification..

Screenshot 2026-01-21 165718.png

 

 

If my response helped mark as helpful and accept the solution..

nayanmule
Kilo Sage

@t venkatesh2  , 

That's right. You have to add images separately in all the notifications. Probably, you can add an image in one of your notifications. You will get the sys_id of the image stored in the 'sys_attachment' table. You can use the same source link in your next notification.

 

nayanmule_0-1768995261837.png

 

If you don't want to repeat the same activity in every notification then better add an email template , add an image there in the template and use the same email template in the notifications where you have to add the image.

 

If my response has helped you , mark it as helpful and accept the solution.

Regards,

Nayan

Ankur Bawiskar
Tera Patron

@t venkatesh2 

Do this

-> open any 1 notification and search that HTML source code

AnkurBawiskar_0-1768999112001.png

 

-> then upload new image to images table

-> then use background script and replace the earlier name i.e. testing.pngx with new name

AnkurBawiskar_1-1768999165425.png

Something like this, please test

// ServiceNow GlideScript (Business Rule, Script Include, etc.) - Server-side safe
function replaceImageSrc(html, oldSrc, newSrc) {
    var regex = new RegExp('src="' + oldSrc + '"', 'g');
    return html.replace(regex, 'src="' + newSrc + '"');
}

// Usage example

var gr = new GlideRecord("sysevent_email_action");
gr.addEncodedQuery("message_htmlLIKEtesting.pngx"); // search those notifications which use that img name
gr.query();
while (gr.next()) {
    var updatedHtml = replaceImageSrc(gr.message_html.toString(), 'testing.pngx', 'new_image.png'); // give old image name and new image name
    gs.info(updatedHtml);

    gr.message_html = updatedHtml;
    gr.update();
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@t venkatesh2 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader