- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2022 09:30 PM
Hi
We need to convert a date to Japanese calendar.
On the client side, dt.toLocaleDateString('ja-JP-u-ca-japanese',{era: 'long'}) works and converts the date to the Japanese calendar without any problem, but
However, the business rule does not work well.
Doesn't it work on the server side?
Please help.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
if (newValue == "") {
g_form.clearValue("end_date_japanese");
return;
}
;
var dt = new Date(newValue);
var japaneseDate = dt.toLocaleDateString('ja-JP-u-ca-japanese',{era: 'long'})
g_form.setValue("end_date_japanese",japaneseDate);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 12:28 AM
toLocaleDateString does not seem to be supported
Created a custom Japanese calendar conversion script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2022 09:47 PM
Hi
You will need to use this script instead of toLocaleDateString to get the same functionality as per your requirement, just change the code as per your req:
https://community.servicenow.com/community?id=community_question&sys_id=02650a271b664c90fff162c4bd4bcb10
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2022 10:30 PM
Can you add the script you use? The current script you added is a client side script. if you are using this in a business rule it will not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2022 11:14 PM
I wrote the following, but the invalid date will be set value.
var date = current.date_field;
var dt = new Date(date);
var japaneseDate = dt.toLocaleDateString('ja-JP-u-ca-japanese',{era: 'long'});
current.japanese_date = japaneseDate;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2022 05:22 AM
what kind of field is "current.japanese_date"? Are you sure the variable japaneseDate has the correct value? and correct value type expected by the current.japanese_date field