- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2016 03:58 PM
I'm interested in making my templates a little bit smarter with a bit of JavaScript. I'm able to set the Caller to myself using this snippet for the value of Caller in the template:
javascript:gs.user_id()
I then tried to set the Short Description using this snippet:
javascript:g_form.getValue('parent.short_description') + ": add some text here"
That resulted in blanking out the short description when the template was applied. I opened the JavaScript executor in Chrome (ctrl-shift-j) while on the record and running:
alert(g_form.getValue('parent.short_description') + ": add some text here")
That gives me a popup alert box with the text I was hoping would populate in the Short Description field. So the script itself appears to be valid and working as I'd expect. But I just can't get it to run when I put it in for the value of a field in a template.
I'm trying this on a developer instance running Geneva.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2016 08:19 AM
Bradley,
The templates apply the javascript server side, not client side. That's why the first call work, gs is available only server side.
With that being said, you can invoke a script include to do what you want. You would have to first create the script include and it would probably look like;
javascript: new bradleysScriptInclude(current, 'parent.short_description', 'add somemore text');
the script include would probably need to look like;
var bradleysScriptInclude = Class.create();
bradleysScriptInclude.prototype = {
initialize: function( /*GlideRecord*/ task, /*string*/ task_field, /*string*/ text) {
this.task = task;
if (!task || !task.isValidRecord()) {
if (!task.isNewRecord()) {
return;
}
}
return task[task_field] + text;
},
type: "bradleysScriptInclude"
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 11:44 PM
I was messing with this after the fact after Christian asked below and I also could not get current to work in any form. Which means, I couldn't get the script include to work as it needs to know what record your on to get it's parent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2017 04:08 PM
Hi Jace
I tried using the script include but am not able to get the current object to work. Is there anything additional i need to do for this?
Thanks
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 07:03 AM
Hi Jace,
I have the same issue here with project apply template. Where did you call the first script include javascript: new bradley.... (from the template record?)
Would really appriciate some help!
/Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2019 03:50 PM
Hi,
As I understand, current may not available in the templates. Instance hardening removed this feature in our case.