I have a relatively big form and multiple users complained about not being able to submit. Nothing on the screes was getting the red highlight which identifies form entry issues. Checking the logs I see: “save ||| DS_VALIDATION_ERROR ||| Some of the elements validation failed”
Why would you say “SOME ELEMENTS” and not have a list of them anywhere?
This makes it impossible to find out the issue with lots of wasted time and headaches.
So, I took it upon myself to find out which items had issues. Hope this code can help other people. It gets all items of the page and check if they are valid, then put them into an array which you can use to log or do whatever you want.
export function myDataset_error(operation, error) {
let errorOp = operation; // “save”
let errorCode = error.code; // “DS_VALIDATION_ERROR”
let errorMessage = error.message;
let items = ;
getInvalidItems($w(“#page1”), items);
logData("dsInscricao_error", operation + " ||| " + errorCode.toString() + " ||| " + errorMessage, items);
}
function getInvalidItems(parent, items) {
for ( let obj of parent.children) {
if (obj.validity && !obj.valid) {
items.push({ id: obj.id, required: obj.required, validity: obj.validity });
}
let id = $w(#${obj.id}
);
if (id.children) {
getInvalidItems(id, items);
}
}
}
2 Likes
Alan, I have had something similar happening on a form: same error, no red borders around culprit. It turned out that I had a numeric field which (under conditions) was Hidden/Collapsed (don´t remember which I used), declared in interface as non-mandatory, databound and, here it comes, with a minimum and a maximum numeric value specified. Turned out that hidden/collapsed + non-mandatory + min-max value specified DOES run a validation, thus returns an error, but since input field is not visible, cannot be seen with a red border.
Maybe this helps.
Exactly! Mine was a similar issue, but my field was visible. It was required, had pattern validation and also custom validation via code. Even though pattern should have passed it was failing and failing the submission. I moved the pattern check into my custom validation. Now I am waiting to see if it will work as expected (as it didn’t always caused trouble - hard to replicate).
The code I provided should help with the discovery though 
Thanx so much Alan,
this code was a life saver…I spent almost 10 hr to find where the error was surfacing from …finally due to this code I found at one place I used toString on number item.
for other developer’s benefit, this is how I added the code>
On my submit button , I added following code>
export function btnSubmitWaveUpdate_click(event) {
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
$w('#dynamicDataset').save();
$w('#txtSubmit').show();
$w('#txtSubmit').text= "Your Values are successfully submitted";
dynamicDataset_error("save","DS_VALIDATION_ERROR") ;
}
export function dynamicDataset_error(operation,error) {
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
let errorOp = operation; // "save"
let errorCode = error.code; // "DS_VALIDATION_ERROR"
let errorMessage = error.message;
let items = [];
getInvalidItems($w("#page1"), items);
console.log ("ds incorrect_error", errorOp + " ||| " + errorMessage, items);
}
function getInvalidItems(parent, items) {
for (let obj of parent.children) {
if (obj.validity && !obj.valid) {
items.push({ id: obj.id, required: obj.required, validity: obj.validity });
}
let id = $w(`#${obj.id}`);
if (id.children) {
getInvalidItems(id, items);
}
}
}
This code fundging saved me it was absolutely brilliant thank you kindly. I had two different areas of my site for adding and I had one of the text entry that wasnt being used was set to required