Extend Date Range To Before 1970 For Custom Fields

Document ID : KB000073538
Last Modified Date : 15/03/2018
Show Technical Document Details
Service Desk Manager/CA CMDB designs Date type as Unix Epoch time, that is, it is stored in mdb as number of seconds since 00:00:00, Thursday, 1 January 1970. However, some custom field dates would need to go before that time. For example, birthday of an contact. Another example is the since-when of the location or site. If designed those custom fields as strings and used them as strings on web interface, there would be a lot of challenges like verifying the calendar and the entry format. This tech doc gives a simple yet effective solution.
How to Extend Date Range to Before 1970 For Custom Fields?
Service Desk/CMDB 12.x, 14.1.x and 17.x
Follow these steps
1. Use standard WSP process to add the custom attribute to the object as a String with size 20
    For example, add a custom size 20 String attribute zbirthday to cnt object
2. Copy v30_date_helper.htmpl file from install-folder\bopcfg\www\htmpl\default  to install-folder\site\mods\www\htmpl\default  and edit this copy file
    like this:
    var z = nowY - 10
    var z = nowY - 150
    and save the change. Please notice that here you let the year go back to 150 years from now and you could need to adjust this number to fit your
3. Copy detail_objname.htmpl file from install-folder\bopcfg\www\htmpl\web\analyst  to install-folder\site\mods\www\htmpl\web\analyst
    For example, copy detail_cnt.htmpl file from install-folder\bopcfg\www\htmpl\web\analyst  to install-folder\site\mods\www\htmpl\web\analyst
4. Edit the detail_objname.htmpl file in install-folder\site\mods\www\htmpl\web\analyst 
    insert these statements into the location you would like the custom field display"
    if ( _dtl.edit ) {
    <PDM_MACRO name=dtlDate hdr="proper-heading" attr=the-cutsom-attribute>
   else {
   <PDM_MACRO name=dtlDate hdr="proper-heading" attr=the-cutsom-attribute size=20>
 also insert "
 var argZrest-of-the-attribute = '<PDM_FMT PAD=NO ESC_STYLE=C>$args.the-cutsom-attribute</PDM_FMT>';
 in the js script var area  and insert "
 <form name="frm002">
<input type="hidden" name="SET.the-cutsom-attribute" value=<PDM_FMT ESC_STYLE=JS2>"$args.the-cutsom-attribute"</PDM_FMT>>

right below <center> tag. Please notice that if you have <form name="frm002"> there already, you don't need <form name="frm002"> and </form> and you only need to insert the <input> statement some where in between.
   and save the change. For example, insert into detail_cnt.htmpl file:
    var argZbirthday = '<PDM_FMT PAD=NO ESC_STYLE=C>$args.zbirthday</PDM_FMT>';
    in js var area and insert "
    <form name="frm002">
<input type="hidden" name="SET.zbirthday" value=<PDM_FMT ESC_STYLE=JS2>"$args.zbirthday"</PDM_FMT>>
   right after <center> tag and finally insert "
    if ( _dtl.edit ) {
    <PDM_MACRO name=dtlDate hdr="Birthday" attr=zbirthday>
   else {
   <PDM_MACRO name=dtlTextbox hdr="Birthday" attr=zbirthday size=20>
  attached is a working file detail_cnt.htmpl for reference. This is for 17.0 and other versions should be similar.
5. Run these two commands 
    pdm_webcache -H
    pdm_webcache -b
6. test
Additional Information:
1.Due to the built-in script for converting date and string values, this simple solution has a minor issue...when edit  existing value of the custom field, the current
value will not display. This minor inconvenience can be overcome by click on "Cancel" button to see the current value.
2. Steps 2 to 6 should be performed on each of the servers in a multi server installation
File Attachments: