Change field label via script

Steven Parker
Giga Sage

So we just upgraded our DEV instance to Jakarta patch 3 and I am having trouble with a script.

This will change the field label in Service Portal, but will not work in the ITIL service view.   The "changeFieldLabel" did work in Helsinki in the ITIL service view, but it throws a JavaScript error in the Service Portal in Jakarta.

Anyone know how to change the field label in the ITIL service view without using "changeFieldLabel"?

find_real_file.png


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
1 ACCEPTED SOLUTION

Hi Steven,



Can you go through this link:


https://www.servicenowguru.com/system-ui/ui-scripts-system-ui/modifying-label-form-fields-client-scr...



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Steven,



So you are saying that code was working fine in Helsinki but doesn't work in Jakarta instance.



Did you check the browser console errors?



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yes this was working fine in Helsinki with the "changeFieldLabel" lines in the code and not commented out.



This is the error I get from the console:



find_real_file.png



Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

Hi Steven,



Can you go through this link:


https://www.servicenowguru.com/system-ui/ui-scripts-system-ui/modifying-label-form-fields-client-scr...



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thank you Ankur!   Mark's bottom script for Catalog Variables helped and is working in BOTH Helsinki and Jakarta:



function changeFieldLabel(field, label, color, weight){


try{


var labelElement = $('label_' + g_form.getControl('job_function').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){};


}



Please mark this response as correct and/or helpful if it assisted you with your question.
Steven