getElementsByClassName
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 06:08 AM
Hi All.,
getElementsByClassName ( on load client script) is not working in service portal. how to replace or any other ideas?
Checked on Isloate script and it is set to be false.
Regards,
Sowmiya
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 06:18 AM
Hi Sowmya,
you need to try to update isolate script as false; this field is available in list layout of the catalog client script and not on form; Also set UI type as ALL
can you share what script you are performing?
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 07:20 AM
Hi AnKur.,
Isolate script was set to false but even then it is not working
function onLoad() {
//Type appropriate comment here, and begin script below
var isNew = g_form.isNewRecord();
var work_notes_hint = 'Can be used to document updates/changes to the Change throughout the lifecycle. This can include date changes, changes to scope (i.e. removal or addition of content), or any other relevant information that should be documented on the change.';
var labels = document.getElementsByClassName("control-label");
if(!isNew){
for(var i=0;i<labels.length;i++){
if(labels[i].innerHTML.indexOf('Work notes')> -1)
labels[i].title=work_notes_hint;
}
}
else{
for(var j=0;j<labels.length;j++){
if(labels[j].getElementsByTagName('span')[1].innerHTML.indexOf('Work notes') > -1)
labels[j].getElementsByTagName('span')[1].title=work_notes_hint;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 07:35 AM
Hi,
what are you trying to achieve using above script? I could see the field hint is being changed
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 08:46 AM
Hi Ankur.,
i m just adding work notes hint for the change.
var labels = document.getElementsByClassName("control-label"); this line only getting an error in service portal.
js_includes_sp.jsx?v=12-2019_1137&lp=Mon_Nov_18_05_25_00_PST_2019&c=8_111:39978 (g_env) [SCRIPT:EXEC] Error while running Client Script "set Work notes Hint": TypeError: Cannot read property 'getElementsByClassName' of null
Regards,
Sowmiya