Month Year Picker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 07:45 PM
Hi All,
Has anyone reconfigured a GlideDate field to pick and display month and year only?
I have been researching it...I found a pure javascript in an html page; there is one about Event.observe in servicenowguru on how to default the time to zero.
I tried combining these but no luck.Any tips or leads is appreciated.
Thanks,
Dor
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 01:38 AM
I've not tried this but you may find you have issues when you write a GlideDate field away without a full date format(e.g dd/MM/yyyy) as when the field reads it back in it'll be out of sync with the entries it expects ... (e.g: MM/yyyy given when it expects dd/MM/yyyy will make MM be read as dd and yy as MM.
I'd say you might be better off creating a new field of type string and adding the calender macro to that. Then add the date format you want from that to your field.
If you need a script to split out the date I can post a script I've created that does this, just let me know.
Maybe someone has some better insights, I'm just spit balling here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 07:14 AM
Hi Daryll,
First of all, thank you for your reply.
Actually, I am very much open to any suggestion.
Unfortunately, UI Macro is not my strong point. For now, I will explore about a UI Macro and calendar.
If you could give some more assistance, that would be really really great.
Thanks,
Dor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 04:13 AM
This is the wiki entry for ui macros http://wiki.servicenow.com/index.php?title=UI_Macros#gsc.tab=0
That should get you started and then on the dictionary definition for the field you wish to add the macro to add 'ref_contributions=<ui macro name>' to the Attributes.
The UI Macro page is written in jelly.
Here's an example (a google maps ui macro) that I've added...
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="open_google_map${jvar_guid}:${ref}"/>
<g2:evaluate var="jvar_show_google_map_display" jelly="true">
var id = __ref__.getSysIdValue();
if (id == null)
"none";
else {
var loc = new GlideRecord('u_social_events');
loc.get(id);
if ((!loc.u_location.nil())
"";
else
"none";
}
</g2:evaluate>
<a id="${jvar_n}"
onclick="openGoogleMap('${ref}')"
name="${jvar_n}"
style="display:$[jvar_show_google_map_display]"
title="${gs.getMessage('Open a Google Map for this location')}">
<img border="0" src="https://maps.gstatic.com/favicon2.ico" height="16" width="16"/> </a>
<script>
needsRefreshLoc = false;
function onChange_location_show_google_map(element, original, changed, loading) {
var s = '${ref}'.split('.');
var referenceField = s[1];
if (needsRefreshLoc == false) {
needsRefreshLoc = true;
return;
}
if (changed.length == 0) {
$('${jvar_n}').hide();
return;
}
var locRec = g_form.getReference(referenceField, locationGoogleMapReturn);
}
function locationGoogleMapReturn(locRec) {
var e = $('${jvar_n}');
if ((locRec.street $[AND] locRec.city) || (locRec.latitude $[AND] locRec.longitude))
e.show();
else
e.hide();
}
//Event.observe(g_form.getControl(${ref}.split('.')[1]), 'change', onChange_cmn_location_show_google_map);
var l = new GlideEventHandler('onChange_location_show_google_map', onChange_location_show_google_map, '${ref}');
g_event_handlers.push(l);
//Pop open google maps window of location specified
//URL should follow this format...http://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003
function openGoogleMap(reference) {
var s = reference.split('.');
var referenceField = reference.substring(s[0].length+1);
var sysId = g_form.getValue(referenceField);
//Retrieve the 'Location' record
var gr = new GlideRecord('u_social_events');
gr.get(sysId);
//Create and display the Map URL
var mapURL = "http://maps.google.com/?q=";
//Try location and city
mapURL = mapURL + gr.u_location;
//Strip '#' symbols to avoid encoding errors
mapURL = mapURL.replace(/#/g, "");
window.open(mapURL);
}
</script>
</j:jelly>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 04:25 AM
Another alternative is to create a second string field that the date is passed into from your date field and then you can manually remove the days from it in an onChange client script (on the date field). This will mean the days are still present when you pick the date but removed in the transfer to the other field.