How i get image from a record in the table?

Alexandre17
Tera Expert

Hello. How i get image from a record in the table?
The problem is: get "current.image_field" to "delivery" to use in the business rule, to generate pdf, like this:

(function executeRule(current, previous /*null when async*/) {
	// Add your code here
	var html = current.html_template;
	var tablename = 'x_577462_limpdocsf_tb7_3';
	var targetTableSysId = current.getValue('sys_id');
	var print_pdf = current.getDisplayValue('emitir_pdf');
	var ano_numero_protocolo = current.getValue('ano_numero_protocolo') ;
	var imagem = current.getDisplayValue('imagem');	//here is the question!
	var data_atualizacao = current.sys_updated_on;
	var numero_nota = current.getDisplayValue('ano_numero_protocolo');
	var fileName = 'Nota n²' + numero_nota + data_atualizacao;
	var a = html.replace('x_ano_numero_protocolo', ano_numero_protocolo);
	var b = a.replace('x_emitir_pdf', print_pdf);
	var c = b.replace('x_imagem', imagem);//here goes to put image
	var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
	var result = v.convertToPDF(c, tablename, targetTableSysId, fileName);
	current.update();
})(current, previous);

"var imagem = current.getDisplayValue('imagem');" not work. 

So, what is the other way? Exist something like current.getImage('field') ? 

 

 

Resolved, by other way.

Created field html, and get current, and after replace

var sys_id_imagem = current.imagem_html;
.
.
.
var c = b.replace('x_imagem', sys_id_imagem);
6 REPLIES 6

Hi. thanks for your attention.

I change the code like this:

//var imagem = current.getValue('imagem');
var imagem = new sn_pdfgeneratorutils.Image(current.getValue('imagem'));

But, in the pdf print like this: 

 

Before

find_real_file.png

after

find_real_file.png

 thanks in advance

Is there a variable named "imagem" on the form? current.getValue() will retrieve the sys_id of the image in the sys_attachment table if there is a variable named "imagem" on the form. If the image is an attachment to the form, it would not.