Javascript formValidation function in ECM (Validation before form submit)

In Javascript, there is this code that should help me configure this function:
image

However, something as simple as that doesn’t work:

window.formValidation.validate = function () {                             
      return false;                                                   
}; 

I get this error in chrome console:
image

Did anyone manage to make the validate function work in ECM? That seems a functionnality that I would use a lot to validate some things or implement new functionnalities but I can’t get to make it work

I have never tried anything like this in ECM.

I hope someone did. They took the time to write 3 blocks of code to help users about Javascript so if one of the block doesn’t have the correct syntax, that’s weird!

I’ve not done this yet either, but looking at the error, I suspect the runtime evaluation of the function is looking for an input that you have not specified. I suspect it’s ‘bad code’ in that it wants something to work with and fails when it’s not supplied. It might not know how to handle you bypassing its internal code to test the function itself. I’d rework the test code to calculate a false value rather than setting a false value and see if that works. Something like the example or (var Nope = 1 > 2)

window.formValidation.validate = function () {   
    var isValid = false;
    return isValid;                                                   
}; 

Something like that still isn’t working. The error message says that window.formValidation is undefined. The difference is that if I use the other bit of code that also uses the window object, that one works:

var handle = setTimeout(function() { var val = "test";}, 100);                          
window.formCleanup.timeOuts.push(handle);  

Because if you log the ‘window’ object, you’ll see that the formCleanup is defined yet the formValidation is nowhere to be seen

Well then… I think I’d open an EpicCare case on this at this point.

1 Like

For sure, I like to post it here since it’s way faster to get actual answers if people already used that. Will try to get back on this thread if I get a fix

1 Like

I will be interested to see if a case yields you any results. 99.99% sure they’re going to say you need a consultant.

They said the same thing last time I talked about forms (The field group thread that I created yesterday). Problem with that is that it should be documented accordingly instead of us paying $$$/h to help fix a bug or something not implemented correctly

Case is created (CS0003993739) so let’s wait and see :popcorn:

1 Like

This may or may not be related but we tried to modify DocStar(ECM) Forms web pages for an integration. We were cloud hosted both for ECM and Epicor 10 at the time, so keep that in mind. Any JavaScript we added was rejected for a CORS violation. And I understand why, a web app shouldn’t allow code to just appear on their pages for obvious security reasons. We abandoned ECM forms and looked at other form-like solutions.

1 Like

Finally found the solution. It was so simple yet I skipped through it everytime

window.formValidation = {}; //THIS LINE IS REQUIRED for us to create the formValidation element
window.formValidation.validate = function () {   
    var isValid = false;
    return isValid;                                                   
}; 
2 Likes