- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 07:31 AM
A record producer (Employment Verification Letters) has one particular field (Travel Date) where, once the date is selected, the format needs to appear UK style (dd/mm/yyyy). I only want to change the date format for this particular field, so I don't want to change the system settings. Is there a variable attribute I can use so the date shows up like that when selected?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 09:05 AM
Hi,
var inputFormat1 = '11/29/2019';
function convertDate(inputFormat ) {
function pad(s) {
return (s < 10) ? '0' + s : s; }
var d = new Date(inputFormat);
return [ pad(d.getDate()),pad(d.getMonth()+1), d.getFullYear()].join('/');
}
gs.log(convertDate(inputFormat1 ))
I ran this script in background script and it is converting date into required format.I think , you need to write this code in script include and populate this value into field using client script.
Please mark it as helpful if it helps.
Thanks,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 08:16 AM
Hi there,
What are you doing with this particular field on the Record Producer? And with field you actually mean variable? Is it just a loose variable, or do you also use it to map it against a field? Should the variable also be changeable or read-only?
If it's just a loose variable and read-only, you could think of having a string type variable, and just reformat the date.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 02:13 PM
This variable will be mapped to the case form. So it can't be a loose variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 09:05 AM
Hi,
var inputFormat1 = '11/29/2019';
function convertDate(inputFormat ) {
function pad(s) {
return (s < 10) ? '0' + s : s; }
var d = new Date(inputFormat);
return [ pad(d.getDate()),pad(d.getMonth()+1), d.getFullYear()].join('/');
}
gs.log(convertDate(inputFormat1 ))
I ran this script in background script and it is converting date into required format.I think , you need to write this code in script include and populate this value into field using client script.
Please mark it as helpful if it helps.
Thanks,
Sumanth