Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#813029
Hello,

after the Update to 3.2.1 (Community) the Datepicker of a datefield doens't work good.
I have a formular which has a datefield in which the minimum selectable date would be dynamical filled with a variable. The minimum date will always be 3 months in the future. I don't want to have always a preselected date so I choose the option false for the preselected date. When I'm now open a case and want to choose a date the datepicker will show me the actual month but I can't select any date and I also can't move into the future months.
I always help myself by typing in a date three months in the future and the open the datepicker. Then it works. In my opinion the forward and rewind button should always work. Also when the days in the month are not possible to select.

Can anyone help me?

Kind regards
#813049
Yes of course I can. Edit: I build a complete new Process with a new Form and had the same problem. I added the new Dynaform which is simplified to just the date Field

And here is my trigger with which I fill the both variables for min and max Value.
//Maximale Laufzeit einer VM 2 Jahre
@@vm_status_runtime_maxdate = date("Y-m-d", (time()+(737*86400)));
//Mindestlaufzeit einer VM 90 Tage
@@vm_status_runtime_mindate = date("Y-m-d", (time()+(90*86400)));


//Frühester Wunschtermin in einer Woche
@@vm_deliver_date_mindate = date("Y-m-d", (time()+(7*86400)));
Thanks
Attachments
(1.75 KiB) Downloaded 274 times
#813054
A possible workaround is to fill the Field with a date in the future and to clear it in the same step.
For that I wrote this javascript.
Code: Select all
if ($("#datetimeVar001").getValue()==""){
  var today = new Date();
  
  
  $("#datetimeVar001").setValue(today.getFullYear() + "-" + (today.getMonth()+4)  + "-" +  (today.getDate()+2));
  $("#datetimeVar001").setValue("");
}
But I'm still the opinion that the backwards and forward arrow should work everytime also when the current month is lower than the minimum selectable date.
#813060
I agree that it is a bug. I filed an internal bug report about it: https://processmaker.atlassian.net/browse/TRI-3288

Here is a JavaScript function that you can use for an datetime field to workaround the problem:
Code: Select all
//works around bug with "min date" and max date" properties if not in the current month 
//by temporarily setting the date and then sets the date back to an empty string
function workaroundMinMax(datetimeId) {
  var oDate = $("#"+datetimeId);
  var minDate = oDate.getInfo().minDate;
  var maxDate = oDate.getInfo().maxDate;

  //set the datepicker to the minDate if greater than currrent month
  if (oDate.getValue() == "" && minDate != "" && moment(minDate).isValid()) {
    var nextMonth = moment().year() +"-"+ (moment().months()+2) +"-01";
    //strip off time information:
    minDate = moment(minDate).format("YYYY-MM-DD");
  
    if (moment(minDate).isAfter(nextMonth) || moment(minDate).isSame(nextMonth)) {
      oDate.setValue(minDate);
      oDate.setValue('');
    }
  }

  //set the datepicker to the maxDate if less than currrent month
  if (oDate.getValue() == "" && maxDate != "" && moment(maxDate).isValid()) {
    var startCurrentMonth = moment().year() +"-"+ (moment().months()+1) +"-01";
    //strip off time information:
    maxDate = moment(maxDate).format("YYYY-MM-DD");
  
    if (moment(maxDate).isBefore(startCurrentMonth)) {
      oDate.setValue(maxDate);
      oDate.setValue('');
    }
  }
}

workaroundMinMax("startDate");
workaroundMinMax("endDate"); 
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]