- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2016 06:17 AM
Is it possible to apply a field style to any value of that field and not just a specific value? If I leave the value field blank, the style doesn't apply. If I enter a single value, then it applies but I would like to format the field with the field style all the time. mlockhart
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2016 06:23 AM
Hi Todd,
Have you tried using a javascript in the "value" field, like explained on our wiki? In javascript you can add condition if value is empty (like for example "javascript: current.state == ''", where state is the field), but you'll have to test it.
Defining Field Styles - ServiceNow Wiki
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 08:17 AM
Good idea Michael to have a field tell you the relative time it's been opened! Figured I see if I can get this created. Is your script similar to the one I came up with?
(function calculatedFieldValue(current) {
// Add your code here
var dateOpened = current.getDisplayValue('sys_created_on');
var today = gs.nowDateTime();
var difference = gs.dateDiff(dateOpened, today, false);
return difference; // return the calculated value
})(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 08:22 AM
Here's what we use. It's a Duration field with a calculated value as follows:
if (current.active == true){
gs.dateDiff(current.opened_at.getDisplayValue(), gs.nowDateTime(), false);
}
The "false" value at the end gives us the format "XX Days XX Hours XX Minutes".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2016 08:25 AM
How do you apply it when you dot-walk to that field on a report?