- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2026 05:51 AM
I shared sample script.
it's obvious you need to enhance it as per your requirement.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2026 07:19 AM
Hi @CharanKulukuri ,
Please refer to the following link. It may help you understand how to apply styles to fields in Service Portal.
Make a variable type Label bold on Service portal
If you found this useful mark it as helpful
Regards,
Iftekhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2026 03:43 AM
Hello @CharanKulukuri ,
Modify and add these lines of code as per requirement
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var title=this.document.getElementById("sp_formfield_text");
if(newValue=="1")
{
title.style.backgroundColor="blue";
}
else
{
title.style.backgroundColor="red";
}
}
// here Element ID is "sp_formfield_+VariableName".
//Prefix "sp_formfield_" is concatenated
//if variable name is subnet_retrieved then element ID is "sp_formfield_subnet_retrieved"
As mentioned by @Ankur Bawiskar DOM manipulation can cause scripts to break or generate unexpected errors especially after platform upgrades.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2026 03:51 AM
Hi @Rakesh_M ,
This kind of worked but the colour changed for field lable but not for value.
Is there a way I can change to for field value rather than field name?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2026 04:04 AM
Hi @CharanKulukuri ,
Please inspect the page and identify the correct element ID for the input field, then update your script to target that element instead.