- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 05:48 AM
Hey guys,
Our ESS portal has recently gone live (finally!). One of our notifications contains the following line: Expect Delivery By: <b>${due_date}</b>
Displaying as: Expect Delivery By: 27/03/2015 00:00:00 PDT
We desperately want to lose the time part of this. I understand we maybe able to do this via a mail script - any help/guidance on this would be much appreciated. I'm not sure where it originated but we have this sample script below (which does not work currently):
<mail_script>
var dueDate = current.due_date.substring(0,8);
template.print("Expect Delivery By:" + "" + dueDate;
</mail_script>
I'll save the whole, how do we show time stamps based on an individual user's location (and the issue of US to non-US date format in notifications) for another day I think!
Many thanks for any help in advance.
Daniel
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2015 01:55 PM
Dates are always an issue in any scripting language, aren't they? I suspect what you are getting is the date as it is stored in the database and not the date as it is typically rendered (say, on a form). Have you tried using the getDisplayValue() method? current.due_date.getDisplayValue() I think this method will return the date the format specified for your instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 06:29 AM
Update! Amending script to:
<mail_script>
var dueDate = current.due_date.substring(0, 10);
- template.print("Expect Delivery By:" + " " + dueDate);
</mail_script>
I.e. close bracket after dueDate (doh!) and changing tsubstring to (0, 10) — including space between , 10 and between " " has resulted in the following now printing:
Expect Delivery By: 2015-03-27
Which is great! Just need to figure out why it's gone to US date format and not kept dd/mm/yyyy!?
Thanks,
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2015 01:55 PM
Dates are always an issue in any scripting language, aren't they? I suspect what you are getting is the date as it is stored in the database and not the date as it is typically rendered (say, on a form). Have you tried using the getDisplayValue() method? current.due_date.getDisplayValue() I think this method will return the date the format specified for your instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2015 03:13 AM
Hi, yep this was exactly the issue. Working script:
<mail_script>
var dueDate = current.due_date.getDisplayValue().substring(0, 10);
template.print("Expect Delivery By:" + " " + dueDate);
</mail_script>
Many thanks.