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

Moderator: amosbatto

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
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 30 times
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 31 times
Slow grid above 20 lines

I have the following problem: I have a grid that i[…]

I cleared the logs in shared/log but it still erro[…]

Thanks amosbatto, How can i create a new plugin […]

Hi coworker the problem seems to be found and so[…]