- 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-11-2016 05:05 AM
You could do this with a little creative scripting. See the g_form.setLabelOf() method.
GlideForm (g form) - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 05:26 AM
Thanks for your quick reply,
i need to write a UI Policy for updating the field labels g_form.setLabelOf based on week_starts_on field
here i hard coded i need condition based on week starts on the remaining week day also i need set the label like
monday(2016-11-07)
tuesday(2016-12-07)
wensday(2016-13-07)
..
.
saturday(.....)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 05:31 AM
Hi,
Since the start date can change based on the "Week starts on" field, you'll need an onChange client script that makes a GlideAjax call to get the new dates.
Client Scripts - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 05:38 AM
can you give any example i alredy gone through those
Thanks!