Why setLabelOf() function is not allowing below code to run in the onload script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2024 11:28 PM
Hii All,
My question is about related to the setLabelOf() function, As i came across that i have used setLabelof() for one field to relabel it then it worked but below code was not running then i commented the code of setLabelof() then below code was running fine, Can i know what is the reason why it is happening like that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 12:09 AM
Hi @Apoorva A H ,
I tried your problem in my PDI and it works for me please use below script
function onLoad() {
//Type appropriate comment here, and begin script below
changeFieldLabel('description', 'My New Label', 'red', 'bold');
}
function changeFieldLabel(field, label, color, weight) {
try {
var labelElement = $('label_' + g_form.getControl(field).id);
labelElement.select('.sn-tooltip-basic').each(function(elmt) {
elmt.innerHTML = label;
if (color)
elmt.style.color = color;
if (weight)
elmt.style.fontWeight = weight;
});
} catch (e) {}
}
Set isolate script to false
Result
Also check
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 12:17 AM
No my question is not about why setlabelof is not working. actually setlabelof is working fine but below code whatever we have written after setlabelof that is not working but if we comment the code of setlabelof then below code works. so what is the reason behind that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 12:18 AM
Can you paste your code below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 12:29 AM
ya sure but basically this is written onload for request view,
if (viewname == 'view_name') {
g_form.setDisplay("fieldname1", true);
g_form.setDisplay('fieldname2', true);
}
for the above following code so in my thing i want to display the two fields for HR partner for the view so i added below the code of setlabelof() then setlabel is changing the label but for the view it is not displaying these two fields. So i commented the first line then it is displaying the 2 fields.