applyTemplate() is not working in before insert BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 11:53 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 11:59 PM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 12:42 AM - edited 10-12-2022 12:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 11:23 AM
worked for me, thanks for your solution.