"Description" HTML variable paste images in Portal

Felipe Morais
Tera Contributor

Hello people,


We have a catalog variable for the Description field, the field type is HTML:

 

FelipeMorais_0-1700041984870.png

 

But an issue was reported. Basically, if I paste an image on the field description, and delete the pasted image before submitting the form, the image still appears on the case follow up

 

FelipeMorais_0-1700041713543.png

 

They don't want to deactivate the feature of pasting images in this field (which I know is possible), only to ensure that this "error" doesn't occur. I'd like to know, is this requirement possible to implement on SN?

Thanks.

Best Regards,

Felipe M.

 
1 REPLY 1

Ryan Duce
Tera Guru

When an image is pasted into a HTML field, the sys_attachment record is created and committed immediately to the database. This allows ServiceNow to render the image preview in the HTML editor properly. I'm not sure this behaviour can be changed short of disabling the paste image functionality which is what you're trying to avoid, but there is another way.

 

The HTML variable itself will have an <img> tag added to it, with a src attribute referencing the newly created sys_attachment record. You'd need a insert business rule / flow to run to find all sys_attachment records with a table_sys_id of the incoming record, and for each attachment sys id, delete it if that sys id is not found in the HTML content of the description.