Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By ic57369k
#795700
Hello,
I have a dynaform where I am choosing start and end dates from the calender. I want to impose following validation rules
1. Start date should be atleast today. Cant be before current date.
2. End date cant be earlier than start date.
3. End Date cant be more than 60 days ahead than start date.
Need a suitable java script.
Thanks and regards
User avatar
By amosbatto
#795726
I had some time to play with this.
First, create a DynaForm which has two datetime fields whose IDs and variables are named "startDate" and "endDate". In each of these field, set their "min date" properties to be: @@minDate
Set these two datetime fields to be required.

Second, add the following JavaScript to the DynaForm:
Code: Select all
getFormById( $("form").prop("id") ).setOnSubmit( function() {
  var startDate = moment( $("#startDate").getValue() );
  var endDate   = moment( $("#endDate").getValue() );
  var diff = endDate.diff(startDate, 'days');
  
  if (diff < 0) {
    alert("The End Date must be after the Start Date.");
    return false;
  }
  else if (diff > 60) {
    alert("The End Date must not be more than 60 days after the Start Date.");
    return false;
  }
});
Third, create a trigger in the process with the following code:
Code: Select all
@@minDate = date('Y-m-d'); 
Set this trigger to fire before the DynaForm.

Here is a sample process to test it:
(36.49 KiB) Downloaded 244 times
User avatar
By amosbatto
#795727
I had some time to play with this.
First, create a DynaForm which has two datetime fields whose IDs and variables are named "startDate" and "endDate". In each of these field, set their "min date" properties to be: @@minDate
Set these two datetime fields to be required.

Second, add the following JavaScript to the DynaForm:
Code: Select all
getFormById( $("form").prop("id") ).setOnSubmit( function() {
  var startDate = moment( $("#startDate").getValue() );
  var endDate   = moment( $("#endDate").getValue() );
  var diff = endDate.diff(startDate, 'days');
  
  if (diff < 0) {
    alert("The End Date must be after the Start Date.");
    return false;
  }
  else if (diff > 60) {
    alert("The End Date must not be more than 60 days after the Start Date.");
    return false;
  }
});
Third, create a trigger in the process with the following code:
Code: Select all
@@minDate = date('Y-m-d'); 
Set this trigger to fire before the DynaForm.

Here is a sample process to test it:
(36.49 KiB) Downloaded 215 times
By nilucshansiva
#827573
Hi @amosbatto,

In my case, users should not be able to select a date older than today. I was able to achieve this using your answer. However I am curious about what we actually do here.

We are actually setting the @@maxDate variable value into date('Y-m-d').
I tried giving this value straight into Max Date property in Dynaform. It did not work.
I tried initializing Max Date property with new Date() (JavaScript) and @@MaxDate = new Date(). It did not work as well.

Is date() is a ProcessMaker specific function? Appreciate your help on this.

Best Regards

As of now I'm still having this problem.

Timeout Not Sending Email

I am confused, but I have setup a self-service as[…]

Hello; In a dynaform (for example: called "Gr[…]

issue with processmaker 3.2

Ok thank you but i have more questions For exam[…]