Calendar(input field) changes but not data. Please help

Hi All, 

Here's the secanio, I made a calender (screenshot attached) from JavaScript(code below). By using this calendar's input I am data limting in vizualisation using code [report date] = DateAdd('dd', -1, DocumentProperty("reportDate")  )  which works perfectly fine every time user selects date. But the problem that i am facing is, when day changes(tomorrow) then only my calendar i.e. input field automatically shows next day(Today) but not my data  in my vizualisation that i am limiting with code [report date] = DateAdd('dd', -1, DocumentProperty("reportDate")  ).  

Example : 

Suppose, Today's date is 1/17/2019. So I select 1/17/2019 in calendar and see data in vizualisation of 1/16/2018 as my code is today-1([report date] = DateAdd('dd', -1, DocumentProperty("reportDate")  ).  ) and then saves it.

when next day, date changes to 1/18/2019,so my calendar input field automatically changes to 1/18/2019 which is awesome but not the vizualisation whose data limit condition is  [report date] = DateAdd('dd', -1, DocumentProperty("reportDate")  ) rather it is showing me data of 1/16/2019. 

So is there any way to fix this.

May be R, IronPython or any conditions/logic in calculated columns can help me or if i can give a placeholder in input field as "Please select date" would work for me but remember my input field is Date type so this might not work. Anyway, Please let me know the better solution to overcome this glitch.  

 

HTML

<FONT size=4> <B>SELECT DATE</B> : &nbsp;&nbsp; 

<SPAN id=dt1picker></SPAN>

&nbsp;&nbsp; 

<SPAN id=dt1><SpotfireControl id="de946cdfdac44114bb80f047b4a7f229" /></SPAN>

<SPAN id=dt1picker></SPAN>

 &nbsp; <SpotfireControl id="e9840dec5d5747eca3ce7c552d7966a4" />&nbsp;&nbsp;&nbsp;

JAVASCRIPT

//constraint date2 calendar based on selection and update property controls automatically

function picker1_onSelect(selectedDate,inst){

    

//console.log('selected ', selectedDate);

//alert(selectedDate);

/*alert(typeof selectedDate);

var selectedDateArr = selectedDate.split("/");

var res = selectedDateArr[1] + "/" + selectedDateArr[0] + "/" + selectedDateArr[2];

selectedDate = res;

alert(selectedDate);*/

 //min date constraint based on other picker 

 minDate = $(this).datepicker("getDate")

 $("#datePicker2").datepicker("option","minDate",minDate);

 var userLang = navigator.language || navigator.userLanguage; 

//alert(userLang);

if (userLang == "en-US") {

  $.datepicker.setDefaults($.datepicker.regional["en-GB"]);

} else {

  $.datepicker.setDefaults($.datepicker.regional["en-GB"]);

}

 

 //update document property after selection

 //$("#dt1 input").focus(); 

 //$("#dt2 input").focus(); 

}

//update document property after selection

function picker2_onSelect(selectedDate){

 $("#dt2 input").focus(); 

 $("#dt1 input").focus(); 

}

//global datepicker options

pickerOptions = {

 showOn: 'button', 

 buttonImageOnly: true, 

 buttonImage: 'http://kalender.isetegija.net/Styles/SandBeach/Images/DatePicker.gif', 

 minDate: "-12M", 

 maxDate: "+1D",

 changeMonth: true,

 changeYear: true,

 dateFormat: 'mm/dd/yy'

}

var today = new Date();

var dd = today.getDate();

var mm = today.getMonth()+1; 

var yyyy = today.getFullYear();

if(dd<10) 

{

    dd='0'+dd;

if(mm<10) 

{

    mm='0'+mm;

}

today = mm+'/'+dd+'/'+yyyy;



//create first date picker

/*document.getElementById('dt1picker').innerHTML="<input type='hidden' id='datePicker1' value="+$('#dt1Label').text()+">"

$("#datePicker1").datepicker(pickerOptions);

$("#datePicker1").datepicker( "setDate" , "01/01/"+new Date().getFullYear());

$("#datePicker1").datepicker("option",{altField:"#dt1 input", onClose:picker1_onSelect})

*/

//create second date picker

document.getElementById('dt1picker').innerHTML="<input type='hidden' id='datePicker1' value="+$('#dt1Label').text()+">"

$("#datePicker1").datepicker(pickerOptions);

$("#datePicker1").datepicker( "setDate" , today);

$("#datePicker1").datepicker("option",{altField:"#dt1 input", onClose:picker2_onSelect})

 

 

Thank You

 

 

Attachments

AttachmentSize
Image icon calendar.jpg7.47 KB

2 Comments

Hi Khushboo, 

Thanks for replying. 

DocumentProperty("reportDate") does not change to next day automatically unless user goes and select today's date in calendar then only it is getting changed. 

So, input field changes automatically to next dat but not doc prop's value, kind of strange.

Please let me know if there's a way.

Thanks

 

 

HS - Jan 18, 2019 - 9:33pm

When it shows next day in input field, did you navigate to Edit > Document Properties> DocumentProperty("reportDate") to see what is actually shows??

Khushboo R - Jan 18, 2019 - 7:15am
+ Add a Comment

(1) Answer

Login