How to populate custom 'Template' field on incident table with name of template applied

jas101
Tera Expert

Hi guys, it's my understanding that's it's still not possible to easily track/monitor template usage.

If this is correct I figure adding u_template field to incident table and getting the value of applied template in said field is best way to do this - I've seen the SNGuru article https://www.servicenowguru.com/system-definition/advanced-templates/ but if I'm honest still not sure what the best/most lightweight option is to parse this value? Does it need to be a client script or can it be a business rule?

@Allen A - maybe you're the man to help again with this one! Thanks.

7 REPLIES 7

Allen Andreas
Administrator
Administrator

Hi there!

You've definitely done so good research already. I've seen this implemented where a custom template reference field (to I believe the sys_template table) is used and filled as part of each template. It's recommend to call it something like: Incident - Service Desk Template, Incident - Network Team Template, something like that with the application prefixed so you can easily see from a 30,000 foot view what type of template was used and allows for scalability for template naming across the platform.

You can then set this reference field to be visible = false using a UI Policy so that the end users don't even see it (if you wanted to hide it, else you could make it read-only). But the field needs to be on the form to be set when the template is applied. You can place this field WAYYYYY at the bottom so that when the form initially loads, it's not even close to their vision and so they don't see it for that split second it appears before the UI policy kicks in. Just my 2 cents.

You can then build a report around this to tap in to your custom template field to get a count of how often it's used, etc.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks for this but to confirm sorry, how would you recommend actually populating the new/custom u_template (reference) field on the incident form i.e how best to get the template name (& prefixing it with table name i.e. 'Incident') into this new field? Thanks!

Hi,

Sure, as part of the template itself, when it's used, it fills in the field for you.

So you would create this reference field to the sys_template table on the table you want to track template use on. Then, build the template.

So to build a template: https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/form-administrati...

For example:

find_real_file.png

Or if the template already exists, open it, and add an entry for your template field and select this template, then save.

So as you can see above, I made a template with those fields and pre-decided values that go in them...so you'd do another entry just like above, with your template field in it and filled in with the current templates selection.

So you'd rinse and repeat for all other templates on the table you're trying to track usage on.

So later on, when you run a report against this table, you can query that "template" custom reference field you made.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Ah I see, that is so simple although leads to a couple of follow-up q's!

Would there be a way to make all new templates automatically just populate this u_template field so we weren't reliant on template creators having to remember/do this (as part of template creation)? Ideally they wouldn't even see the field on the template form.

Secondly, could I easily populate this field for existing active incidents (or indeed all incidents that have used a template)? Would this have to involve something like a Fix Script? Thanks!