- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 02:31 PM
Hi all,
So, I am trying to apply a template from a workflow activity.
I tried this in the workflow activity, but to no avail, so any input or direction would be most appreciated.
task.applyTemplate('u_template__1'); //u_template__1 is the name of the template I am trying to apply |
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 12:24 PM
Hi Michael,
Template(s) being applied is from one of 5 template variables (each a
separate reference field to sys_template table, on the sc_cat_item table.)
The workflow iterates through each of the templates,if not empty, applies
the template.
This is what ended up working in the script area of the Catalog Task
activity
task.applyTemplate(current.cat_item.*name of the template variable goes
here*.name +'');
On Wed, Apr 1, 2015 at 11:08 AM, Michael Ritchie <

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 05:50 PM
Can you post a screenshot of your workflow activity?
Also, what order is your workflow set to?
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 06:12 PM
Are you creating this task in the workflow? If so one of the options in the create task activity is to apply a template as it is getting created.
If you are trying to apply a template to an inflight task then you can add a run script activity and put current.applyTemplate('templateName').
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 10:03 AM
Hi Michael,
Thanks so much for getting back to me.
I updated my workflow and added the "Catalog Task" activity to the workflow
and then set the "Task value from Template" on the activity.
This worked perfectly when I selected a specific template.
My struggle is that I am trying to apply a template to an in-flight catalog
task. The template to be ideally applied to the catalog task is from a
reference field on the Catalog Item table called (u_template__1).
This reference field (u_template__1) has a specific value in it, but it is
"dynamic", allowing the user building the catalog item to choose various
templates. So I am trying to pull the value of whatever is stored in that
reference field (u_template__1) and apply that template.
Does that make sense?
On Tue, Mar 31, 2015 at 6:12 PM, Michael Ritchie <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 11:08 AM
Corey, thanks for the clarification. Is there a reason you want to apply this template with the workflow? I am thinking a better alternative is to apply it when the user sets the template in the catalog task. You could create a business rule on the sc_task table that looks for changes in the u_template__1 field and if found execute:
current.applyTemplate(current.u_template__1)