- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 02:26 AM
To further increase usability on time entry, let's have a way to display the actual date for the days of the week on time cards. There is a field for each day of the week.
i need to write a ui policy for that displays the correct date next to each day of the week field
This can key off of the week start date. To display, let's update the field lables (g_form.setLabel) to match the following example: "Tuesday (7/5/2016)"
Thanks!
Solved! Go to Solution.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2016 08:16 AM
Hi Murali,
You need to call "printdate" function in onCondition() function. I put few alerts as well in code now. If everything is good, remove those alerts. Or else let us know, what are the alerts you are getting.
function onCondition() {
printdate();
function printdate()
{
alert("Inside printdate function");
var g_form = new GlideForm();
var fields = ["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];
for(var loop = 0 ; loop < 7 ; loop++)
{
var dtDate = new Date();
dtDate.setDate(dtDate.getDate() + loop - dtDate.getDay());
var frmtval = getDateLabel(dtDate);
alert(frmtval);
g_form.setLabelOf(fields[loop],frmtval);
}
}
function getDateLabel(dt)
{
alert("inside getDate label function");
var weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var fmt = dt.getMonth()+1 + "/" + dt.getDate() + "/" + dt.getFullYear();
return weekday[dt.getDay()] + '(' + fmt + ')' ;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2016 03:07 AM
Hi Murali,
That's a minor change.
dtDate.setDate(dtDate.getDate() + loop - dtDate.getDay());
From above line, remove dtDate.getDay() part.
dtDate.setDate(dtDate.getDate() + loop);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016 03:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2016 03:26 AM
Hi Murali,
var dtDate = new Date();
Please change above line of code to below.
var dtDate = new Date(g_form.getValue('your week start date field'));
I was initializing to current date, hence though you select other dates, it calculates from current date. Now, you can see, we are taking the value from "week start date" field. In above line, put your week start date field name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016 05:55 AM
Ram,
This concept is great in theory, however, I am receiving an error, and most likely you will be able to assist.
In the code, I left the alert(frmtval) and receive a undefined(NaN/NaN/NaN) error.
function onLoad() {
printdate();
function printdate() {
var g_form = new GlideForm();
var fields = ["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];
for(var loop = 0 ; loop < 7 ; loop++) {
var dtDate = new Date(g_form.getValue('week_starts_on'));
dtDate.setDate(dtDate.getDate() + loop);
var frmtval = getDateLabel(dtDate);
alert(frmtval);
g_form.setLabelOf(fields[loop],frmtval);
}
}
function getDateLabel(dt) {
alert("inside getDate label function");
var weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var fmt = dt.getMonth()+1 + "/" + dt.getDate() + "/" + dt.getFullYear();
return weekday[dt.getDay()] + '(' + fmt + ')' ;
}
}
Any thoughts? Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 07:37 AM
Also, what happens when your week crosses months?