- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 02:06 AM
Hello,
I have one field on form and I want to show it in red colour when the record is in-active.I have added styles in configure styles but its working only in list view not on form..can anyone suggest whats wrong here..
Table :xyz
Field name : Name
Value : javascript: current.status='Active'
Style : background-color:red
Solved! Go to Solution.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 02:11 AM
Hi,
if you give value then it would apply only on list
to make it work on form do this
create onLoad client script
function onLoad() {
var control = g_form.getControl('status');
var status = g_form.getValue('status');
if(status.toString() == 'true'){
control.style.color = 'blue'; // to set the color of field
control.style.backgroundColor = "red"; // to set the background color
}
}
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-12-2021 02:11 AM
Hi,
if you give value then it would apply only on list
to make it work on form do this
create onLoad client script
function onLoad() {
var control = g_form.getControl('status');
var status = g_form.getValue('status');
if(status.toString() == 'true'){
control.style.color = 'blue'; // to set the color of field
control.style.backgroundColor = "red"; // to set the background color
}
}
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-12-2021 03:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2021 04:05 AM
Hi,
yes onload of the table on which field is present
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-16-2021 01:42 AM
Hope you are doing good.
Did my reply answer your question?
If so, please my response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader