How to change field color based on the field value calculation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 07:13 AM
Hi all,
We have a requirement in scoped application.
There are three fields 1. Net Amount 2. Additional Charges 3. tax amount.
if the calculation of these three fields are equal to Total amount. Then Another field Named Balance field need to be displayed as "OK " and field color needs to be displayed as yellow else it should be displayed as "pending" and field color need to be displayed as "Red " and set the field value as "Pending".
Please help me with the best way to achieve this.
Thank you,
Balaram.
- Labels:
-
Incident Management
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 07:16 AM
Hi,
Thanks for posting your requirements for us...
What have you tried so far? What have you looked into (documentation wise)?
What is working? What is not working?
We'd love to help you learn.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 07:22 AM
Hi,
should be something like this in onChange client script wherever you are doing the calculation
you can enhance it as per your requirement.
reference: Background colour in fields
// your logic here
var field = g_form.getControl('balance');
if(condition){
field.style.backgroundColor = 'yellow'; // sets background color
field.style.color = 'red'; // sets color to value
}
else{
g_form.setValue('balance', 'Pending');
field.style.backgroundColor = 'red';
field.style.color = 'blue'; // sets color to value
}
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-09-2022 01:45 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
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-22-2022 06:49 AM
Hope you are doing good.
Did my reply answer your question?
Would you mind closing the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader