applyTemplate() method not available in scoped applications

cmcclendon
Mega Guru

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.

7 REPLIES 7

hadyndickson
Mega Expert

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;


              }            


      }    


  }


};


The SN Nerd
Giga Sage
Giga Sage

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);




ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

This is handy, but I couldn't find GlideTemplate in the documentation.   Does that mean using it is not supported?


That is a question only ServiceNow themselves can answer



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022