Get image from image field in a table

Mario Tartaglia
Tera Contributor

Hi everyone,

I am trying to insert an image into a PDF document template.

The picture is in a table as shown below:

find_real_file.png

In my pdf I would like to return the image and I have tried:

(function evaluateMappingFieldValue(caseGr /* GlideRecord for parent case */ , mappingField /* Pre-computed mapping field value */ ) {

var gr = new GlideRecord('sn_hr_core_profile');
gr.addEncodedQuery('u_firma!=NULL');
gr.query();
if (gr.next()) {
var firma = gr.getDisplayValue('u_firma');
}
return firma;


})(caseGr, mappingField);

it returns d58a33a787274d1040d262c80cbb3524.iix which is the sys_id in sys_attachment table.

How can i get the image?

p.s. this is an example query, i think the problem is var firma = gr.getDisplayValue('u_firma');

1 ACCEPTED SOLUTION

michaelj_sherid
ServiceNow Employee
ServiceNow Employee

@Mario Tartaglia A good step will be to look at the OOTB hr_PDFUtils script include. In that SI we are capturing the signature image so this will be helpful for you to use this as a guide. You can look at the function - mergeSignatureImageToPdfUsingItext7 to understand how you can accomplish this for your use case.

Regards,

Mike

View solution in original post

1 REPLY 1

michaelj_sherid
ServiceNow Employee
ServiceNow Employee

@Mario Tartaglia A good step will be to look at the OOTB hr_PDFUtils script include. In that SI we are capturing the signature image so this will be helpful for you to use this as a guide. You can look at the function - mergeSignatureImageToPdfUsingItext7 to understand how you can accomplish this for your use case.

Regards,

Mike