How can I automatically populate child templates without creating a module?

jamie_girouard
Giga Expert

One of the issues I'm having right now is creating a way for a user to apply a template and have the child templates applied...WITHOUT having to resort to this model where you have to create a template for the module:

 

Creating a Template for Change Request Tasks - ServiceNow Wiki

 

The reason this is a problem is that once you invoke the module, the tasks are created - so if you fat finger or accidentally click that link, you have a change request and change tasks that are created inadvertently.   That's really not ideal, especially when we send out notifications on the creation of change tasks.

 

So what I've been able to do are two things - first, I added a field called u_template (Template) to our task table, and then modified the UI Macro that generates the Apply Template menu item to populate that field.   Second, I created an after business rule on change_request that will query for the child templates and apply them accordingly if we identify that the template field has been populated.

 

Now this works fine - provided I'm in the admin role.   If I'm not in the admin role, then it will only apply templates that are either global or available to that particular group.   In that case, it won't even bring up the templates in my query.

 

So am I doing this wrong?   Or has anyone figured out another way to do the "parent template/child template" thing without having to put the invocation of that into a module?

2 REPLIES 2

JusCuz
Tera Guru

Well I'd say you aren't doing anything wrong at all. A template that is not global or in a group can only be used by the person that created it.



I had the same requirement however, the way I went about it was to first implement the advanced templates from ServiceNowGuru, then in the workflow I checked to see if the u_template field was populated, if so then ran a script that included all the related task templates.


Thanks for the info.   I ended up basically giving up on this approach, and simply turning all of these modules into Service Catalog items.   Which ended up working out much better in the end.