How to use image type field with hr document template.

kiran44
Tera Expert

We are capturing the user’s signature through a widget in the record producer and storing it in an image field called “u_sign_image” on the HR case table. However, when we attempt to include this signature in the HR document template using the “u_sign_image” field, it does not appear in the generated PDF. 

1 ACCEPTED SOLUTION

Hi @Sandeep Rajput 
Thank you for your response. I managed to resolve this by replacing the image type field with an HTML field. I then wrote a business rule to generate an HTML image tag, using the source from the attached signature in the sys_attachment table. This HTML value was added to the HTML field on the table.

Now, I simply select that HTML field in the HR document template, just like any other field, and the signature image is included.

View solution in original post

9 REPLIES 9

@kiran44 This is expected and the image is not going to be added automatically within the document. You can refer to this article https://www.servicenow.com/community/developer-articles/add-an-image-signature-in-a-pdf-using-quebec... and see if it helps to embed the image in your document.

Hi @Sandeep Rajput 
Thank you for your response. I managed to resolve this by replacing the image type field with an HTML field. I then wrote a business rule to generate an HTML image tag, using the source from the attached signature in the sys_attachment table. This HTML value was added to the HTML field on the table.

Now, I simply select that HTML field in the HR document template, just like any other field, and the signature image is included.

Hi @kiran44 ,
Will you please help me with you script used in hTML template as well as in Business rule as I have same requirement.

Thanks!

I'm editing this duplicate reply since I don’t see an option to delete it.

Hi @Drishti ,

Business Rule used to construct an HTML string containing the image attachment (signature) and populate it into the u_sign field:

var recordId = current.sys_id;
var attch = new GlideRecord('sys_attachment');
attch.addQuery('table_sys_id', recordId);
attch.addQuery('table_name', 'sn_hr_core_case_total_rewards');
attch.addQuery('content_type', 'image/png');
attch.query();

while (attch.next()) {
var attachImage = '<img src="/sys_attachment.do?sys_id=' + attch.sys_id + '" width="120" height="50"/>';
}

current.u_sign = attachImage;

 

Then I just added u_sign field in Document template using selected variables:

kiran79_0-1757657323149.png

 

Since the case flow is managed via Flow Designer after the case is created, we replaced the Business Rule with a Flow Action that replicates the same logic:

A Lookup Records action is used to fetch the relevant image attachment by applying conditions similar to those in the original Business Rule.
Once the attachment is retrieved, we construct an HTML string using the attachment’s sys_id.

The Update Record action used set the u_sign field with the constructed HTML string, along with other field updates.

kiran79_1-1757657374228.png