applyTemplate() method not available in scoped applications
This content was last updated in 2020. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2016 06:31 AM
I'm writing a custom application in the Fuji release, which requires scoped applications. When I try to use the applyTemplate() method in an OnSubmit Business Rule, I receive an error stating that this method is not supported in scoped applications. Any ideas?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2017 09:31 PM
I had the same issue. I had to roll my own "applyTemplate" function. You could probably use this as a boilerplate, it works for my needs.
var applyTemplate = function(template,record){
if(template.getTableName() !== 'sys_template'){ return false;}
var fields = template.template.replace('^EQ','').split('^');
for(var i in fields){
var kv = fields[i].split('=');
var k = kv[0];
var v = kv[1];
if(record.hasOwnProperty(k)){
try {
record[k] = v;
} catch (e) {
return false;
}
}
}
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2017 06:26 PM
This worked for me
var sys_id_of_template = '56a8e507db6b26405accd5f0cf96190b';
var grObj = new GlideRecord('incident');
var t = new GlideTemplate.get(sys_id_of_template);
t.apply(grObj);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:11 PM
This is handy, but I couldn't find GlideTemplate in the documentation. Does that mean using it is not supported?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:34 PM
That is a question only ServiceNow themselves can answer