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

Moderator: 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 eventoteam
#794170
Since the last time i saved the Form its Showing the JS written at the end of the case.
Attaching the snapshot of it.
Would be Glad if you let me know how to resolve this Issue.
Attachments
2017-08-03_16-03-10.png
2017-08-03_16-03-10.png (141.77 KiB) Viewed 3298 times
By eventoteam
#814135
Got this code from our team. Kindly let me know the correction needed.
Code: Select all
function validateGrid() {
   var totalRows = Number_Rows_Grid("Level1InvestigationNotes", "SLA_Action_Level1");
   var a = (getField("dtLoggedOn").value);
   var d = "20"+a[0]+a[1] +  "-" + a[2]+ a[3] + "-" + a[4]+a[5];
   var f = new Date(d);
   var e = (getField("dtReportedOn").value);
   var reportdate = e[0]+e[1]+ e[2]+ e[3]+e[4]+e[5]+e[6]+e[7]+e[8]+e[9];
   var reportdate1 = new Date(reportdate);

   if (reportdate1 > f) {
     alert ("ReportedOn Date should be less than or equal to Logged On Date ");
     return false; 
   }
   else {
      return true;
   }

   for (var i = 1; i = totalRows; i++) {
   
      if (getGridValueById("Level1InvestigationNotes", i, "SLA_Action_Level1") == "") {
         alert("Please choose SLA Action in Level 1 Investigation Grid", "Error");
         return false;
      }
      else if (getGridValueById("Level1InvestigationNotes", i, "SLA_Action_Level1") != "Reported On") {
          alert ("Please note that the first row should have 'Reported on' as the SLA Action of Level 1 Investigations");
          return false;  
      }
      else if (getGridValueById("Level1InvestigationNotes", i, "dtLevel1InvestigationDoneOn") == "") {
          alert("Please enter the  Investigation Performed on Level 1 Investigation Grid", "Error");
          return false;
      } 
      else if (getGridValueById("Level1InvestigationNotes", i, "dtddForLevel1Investigation") == "") {
          alert("Please enter the DD Level 1 Investigation in  Level 1 Investigation Grid", "Error");
          return false;
      }                  
      else if (getGridValueById("Level1InvestigationNotes", i, "CmbPersonAssigned") == "")    {
          alert("Please choose the Performed By in  Level 1 Investigation Grid", "Error");
          return false;
      }  
      else if (getGridValueById("Level1InvestigationNotes", i, "txtTimeTaken") == "") {
          alert("Please enter the Time Taken in Investigation Grid", "Error");
          return false;
      }
      else if (getGridValueById("Level1InvestigationNotes", i, "txtTimeTaken") == 0) {
         alert(" Time Taken in level 1 Investigation Grid should not be 0", "Error");
         return false;
      }
      else if (getGridValueById("Level1InvestigationNotes", i, "dtLevel1PersoneAssignedon") == "") {
         alert("Please enter the Assigned on date in  level 1 Investigation Grid", "Error");
         return false;
      }
      else if (getGridValueById("Level1InvestigationNotes", i, "dtLevel1PersoneAssignedon") == 
          (getGridValueById("Level1InvestigationNotes", i, "dtLevel1InvestigationDoneOn")))
      {
          alert("Assigned on and Performed on Date/Time should not be Equal ", "Error");
          return false;
      }
      else if (getGridValueById("Level1InvestigationNotes", i, "dtLevel1PersoneAssignedon") >= 
          (getGridValueById("Level1InvestigationNotes", i, "dtLevel1InvestigationDoneOn")))
      {
         alert("Performed on date should not be less than Assigned on Date", "Error");
          return false;
      }
      else {
          return true;
      }
   }
}

getField('btnSubmit').onclick = validateGrid; 
User avatar
By amosbatto
#814137
First of all, please take the time to use proper spacing so that your code is readable and use the code button in the editor. Otherwise, nobody will help you because your code is impossible to read. I just edited your post to reformat your code so it would be readable.

Your alert() calls will generate errors because that function only accepts 1 parameter, not 2. If you want a title in your error messages, you need to use G.alert() in place of alert().

You need to run this code with your web browser's debugger enabled to see any errors. You have probably misspelled a field name. In Chrome and Firefox, press F12 to activate the debugger.

If you still can't figure it out, then post the complete xml code for the Dynaform.
By markcowell23
#826136
eventoteam wrote: Thu Aug 03, 2017 7:06 am Since the last time i saved the Form its Showing the JS written at the end of the case.
Attaching the snapshot of it.
Would be Glad if you let me know how to resolve this Issue.
i'm facing the same issue

Hello ProcessMakers! We are extremely proud to an[…]

How processmaker load cases on home page of user? […]

Hey everyone, I'd appreciate any help you might be[…]

Error dynaform xml pm3

Thanks for sharing .