OnLoad Client Script g_form.setLabelOf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 12:41 PM
Hello,
I am looking to dynamically update a field label on a form based on the values in a the sys_class_name on alm_asset table using Onload Client script. as per my example below, if the sys_class_name is Kittens, I would like to update the serial_number field label to Cats. I was successful is using this same idea using the state field, But then I could reference the actual value of the choice selected. Not sure if this is possible on the sys_class_name option.
Thanks,
function onLoad() {
//Type appropriate comment here, and begin script below
var type = g_form.getValue('sys_class_name');
if (type == "Kittens"){
g_form.setLabelOf('serial_number', 'Cats');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 07:34 AM
Hi @Cobee,
As a best practice, you have to use the Dictionary approach shared by me & @Alex Coope - SN.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 08:06 AM
Ok. so on alm_asset table I am looking to have the label for "Serial Number" display as "Cereal Number" when the sys_class_name = Captain Crunch, else display as "Serial Number".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 08:10 AM - edited 01-16-2023 08:12 AM
@Cobee,
But what's the process / business need for that?
Sometimes we have to evaluate that just because we can do something, it might not be the best thing to do if we do it and weighing up the pro vs con of the action is just as important,
(update) - if it's just to do it for something like a hackathon, then what you should do is extend [alm_asset] so you have an extended table of [alm_asset_cereals] then create a label in [sys_documentation] for that table's "element" of "serial number" to be "Cereal Number". That would be the best practice approach,
Many thanks,
kind regards
Director of Globalization Deployment, Internationalization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:09 AM
Thanks for the guidance here Alex and Sagar. Much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 08:20 PM
Hi @Cobee,
It would be helpful for future readers, if you mark it as correct answer.
Thanks,
Sagar Pagar