applyTemplate() is not working in before insert BR

Yash31
Tera Contributor

Hello All,

I am working on a BR where I need to apply a template on an incident record and check if it is valid.

I am using following code:
var recordGr = new GlideRecord(templateGr.getValue('table'));
recordGr.initialize();
recordGr.applyTemplate(templateGr.getValue('name'));
 

Once, after this when I check recordGr in debugger, all values are undefined. Ideally it should set the values from template.

Any idea? Why this must be happening?

3 REPLIES 3

Sai Kumar B
Mega Sage
Mega Sage

@Yash31 

Can you try the following?

var sys_id_of_template = 'sys_id_of_template';   
var recordGr = new GlideRecord('table_name');
var t =   new GlideTemplate.get(sys_id_of_template); 
t.apply(recordGr); 

@Sai Kumar B  Not working this way either.

 

Thanks,

Yash

worked for me, thanks for your solution.