Every couple of years the same idea pops up in my head: Why don’t we use Field styles for X?
Having all the field styles in a single table. What a great idea!
Unfortunately, this is probably the most inconsistent piece of functionality in the Servicenow platform.
I will try to summarise this erratic behaviour and save my future self some headaches the next time I try to go down the same rabbit hole.
Summary
With conditions / value | No conditions / value | |
---|---|---|
Form | NO 🚫 | YES ✅ |
List | YES ✅ | NO 🚫 |
Form (pop up view) | YES ✅ | YES ✅ |
List (pop up view) | NO 🚫 | NO 🚫 |
API | NO 🚫 | YES ✅ |
Service Portal | NO 🚫 [you can modify your widgets] | NO 🚫 [you can modify your widgets] |
Workspace | NO 🚫 [1] | NO 🚫 [1] |
Mobile | NO 🚫 [2] | NO 🚫 [2] |
Polaris | Same as UI16 [3] | Same as UI16 [3] |
Now, let’s go for a walk and see how it looks!
With conditions / value
We are not going to create any custom styles yet.
Let’s just check some out of the box styles for Tasks with Priority 1 or 2.
![](https://rubenferrero.com/wp-content/uploads/2022/10/image.png)
🚫 Form 🚫
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-1-1024x523.png)
✅ List ✅
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-2-1024x333.png)
✅ Form (pop up view) ✅
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-3.png)
🚫 List (pop up view) 🚫
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-4-1024x385.png)
🚫 API 🚫
var grIncident = new GlideRecord('incident');
if (grIncident.get('e8e875b0c0a80164009dc852b4d677d5')) {
gs.print(grIncident['priority'].getFieldStyle());
}
//Result: *** Script: undefined
Code language: PHP (php)
Without condition / value
Let’s repeat the tour after removing the out of the box Field styles and adding just a custom one without condition/ value.
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-5.png)
✅ Form ✅
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-6-1024x530.png)
🚫 List 🚫
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-7-1024x320.png)
✅ Form (pop up view) ✅
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-8.png)
🚫 List (pop up view) 🚫
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-9-1024x412.png)
✅ API ✅
var grIncident = new GlideRecord('incident');
if (grIncident.get('e8e875b0c0a80164009dc852b4d677d5')) {
gs.print(grIncident['priority'].getFieldStyle());
}
//Result: *** Script: background-color: lightblue
Code language: PHP (php)
[1] Agent workspace
Field styles are ignored. You need to configure a specific feature for Agent workspace: Highlight list fields.
[2] Mobile
Field styles are ignored. You need to configure a specific feature for Mobile: Mobile UI Styles
[3] Polaris / Next Experience
It looks similar to the Workspace UI “Highlight list fields” in the list view, but the behaviour is the same as in the “old UI”.
![](https://rubenferrero.com/wp-content/uploads/2022/10/image-14-1024x343.png)
Will servicenow ever fix this?
Servicenow is well aware of this erratic behaviour, and they even posted a video on September 2022, suggesting code duplication and DOM manipulation as a workaround. So, I don’t expect this feature to be fixed any time soon.