- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2017 11:45 AM
I need to set that label for 'Task' (for Time Cards in this case) to the Task Type of the record within the field.
function onCondition() {
var task1 = g_form.getReference('task');
g_form.setLabelOf('task', task1.getTableName());
}
This nets me 'task' for the label, I suppose it is the task table, but not what I want. So I tried this:
function onCondition() {
var task1 = g_form.getReference('task');
g_form.setLabelOf('task', task1.sys_class_name);
}
This nets me (for example) 'pm_project' for a Project. I'd like to build this so I don't have to setup every possible option for types of records we could have in there in a way that doesn't look goofy to the User, thus why I want the table name.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2017 06:27 AM
In that case, I would recommend using both methods and getting creative with when each is called. If starting from a Task's related list, use the onDisplay Business Rule and a client script that sets the label. If starting from Time Card directly, use an onChange client script that calls a script include to return the value of the table's label and set the field label.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2017 11:07 AM
That did it, thx for the assist Tim!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2017 07:52 AM
You can consider using the Dictionary Override from ServiceNow to update the labels for each task type. By that way you can ignore creating scripts for setting the label for each task type you are going to created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2017 07:54 AM
How can Dictionary Override be used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2017 07:56 AM
He is trying to set the Task field label on the Time Card form. Dictionary Override would not work for this.