Scripting in templates?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2015 05:53 AM
Hi,
I am looking for a way to create task templates with dynamic task description field. Has anyone come across a similar need and can share a solution?
For example, suppose there is a template named 'Task for Fax Vendor' for the sc_task table. When defining a template I would write in the description field something along the lines of:
Please create a fax subscription according to the details below.
Fax Number: ${current.variables.fax_number}
Add to global address list: ${current.variables.add_to_gal}
And then when the template is applied (manually or from a script) the code in the description field template evaluates and the actual task description would be like:
Please create a fax subscription according to the details below.
Fax Number: 1-123-1234568
Add to global address list: true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2015 06:19 AM
I've used this syntax previously to autopopulate with a ser in a template user reference type field
javascript:gs.getUserID();
so you could try javascript: current.variables.fax_number;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2015 09:32 PM
Hi Marc,
Yep, I see your point. Indeed this would be one way to create such templates. However, this is not what I am looking for in this case.
What I need is something similar to email template scripts. That is, even though it is possible to define task description by saying description = javascript:SomeScriptIncludeToProduceTaskDescription(); it is not very practical for these reasons:
- you would want to make small changes directly in the template without the need of changing the script include every time when a need arises.
- what's more important, you'd want that certain process uses who do not have rights/skills to update script includes would still be able to modify the template.
Regards,
Viktor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2015 09:34 AM
As Marc has already pointed out, you can make use of JavaScript in templates. To achieve what you want, create a script include to retrieve the necessary data and generate the description and then call it from the template using javascript: prefix. One thing I am not sure about is whether templates are the best solution in this case. Have you considered automatically generating the task with appropriate description if the vendor needs to be involved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2015 09:34 PM
Hi Slava,
What you describe is actually my current approach. These tasks are generated from a workflow - each with its own script. This is not convenient for the reasons I described in my reply to Marc.
Regards,
Viktor