Form Validation Failing - Not Consistent


Badge +5

I am working on a SharePoint form that has multiple validation options based on end user selection. There are about 13 options (drop-down) in total and I am having a similar issue with about 3 of them: the validation is acting erratically. The code for one is below. I have tried several things to fix the issue:

  • Retyping the code
  • Removing and rebuilding the fields from the SharePoint side
  • Breaking them up into multiple rules

No mater what I still get the same or similar end result: The validation treats the code as if there are separate. Once the first group is filled in (Up to Zip Code) the form then can save with the balance being empty. There are other validation rules that use some of the same fields and it's ok for them. Not sure what to do. I did read post regarding an know issue with Content Types and this type of errors being produced.  REVIEW TYPE is the trigger.

ReviewType=='Available Capacity'&&(isNullOrEmpty(trim(CustomerCompanyName))||isNullOrEmpty(trim(ResourceCenterDistrictLocation))||isNullOrEmpty(trim(StreetAddress))||isNullOrEmpty(trim(ZipCode))||isNullOrEmpty(trim(HourlyLoad))||isNullOrEmpty(HourlyLoadUnits)||isNullOrEmpty(trim(DailyLoad))||isNullOrEmpty(DailyLoadUnits)||isNullOrEmpty(trim(DeliveryPressurepsig)))

The form

When the user has to enter data initially:

Initially B

Initially A

After some data filled in: *IF anything in the top group is not filled in then the validation fails but if they are filled in it lets the user save even if none of the ones below are populated.

This should be still not valid: but the user can save


24 replies

Badge +5

Related article: https://community.nintex.com/message/83267-re-how-to-not-allow-users-to-enter-a-blank-space-in-a-field-field-validation?… 

Userlevel 5
Badge +14

Looking at the code you have provided: 

ReviewType == 'Available Capacity' && 
(
  isNullOrEmpty(trim(CustomerCompanyName)) ||
  isNullOrEmpty(trim(ResourceCenterDistrictLocation)) ||
  isNullOrEmpty(trim(StreetAddress)) ||
  isNullOrEmpty(trim(ZipCode)) ||
  isNullOrEmpty(trim(HourlyLoad)) ||
  isNullOrEmpty(HourlyLoadUnits) ||
  isNullOrEmpty(trim(DailyLoad)) ||
  isNullOrEmpty(DailyLoadUnits) ||
  isNullOrEmpty(trim(DeliveryPressurepsig))
)

The only thing that sticks out is the missing 'trim' functions from two of your arguments.

That being said, it might be a lot easier to figure out what's happening if you just gave each Control its own Rule written simply like: 

ReviewType === 'Available Capacity' && isNullOrEmpty(trim({Control:Self}))

Being that, that's all you seem to actually be checking for each one of these Controls. 

Badge +5

Thanks for the reply! 

  • I left the TRIM off  two of the controls because they are drop downs 
  • The thing about this form is that is is just one of 13 options sad.png  And the whole thing is not valid is ANY of them are not populated (In this case for Available Capacity) 
  • I did test a while back by breaking into smaller "groups" - tow validations and running. SAME result even though they were not in the same statement
  • I also went as far as deleting all the controls in that section and re-adding them 
  • The ODD thing is since testing Available Capacity by removing the TRIM - it works. EXCEPT users can enter a blank apace  sad.png 
    • I was thinking of adding a RegEx component to the control itself but so far I am not able to make it work  
Userlevel 5
Badge +14

I guess maybe I'm not understanding something. 

  • Could you maybe describe how / where you are applying the rule code from above?
  • Are you putting that rule on all of your controls? 
  • Do you also want to account for whatever values exist in the ReviewType control?
  • You seem to suggest that the controls should be invalid if they are blank... if that's the case, then why does it matter what the value of ReviewType is? 
Badge +5
  • As of right now there are rules for each option: The form has 13 "options" that each have a specified set of required fields.  Each review type has varying "Required" fields 
    • So the ReviewType== is each review type 
  • The rules above are all done using the Rules panel:  
    • NAME: Rule Type: Validation Condition....
  • Each individual control currently has no validation attached to them directly in the Control Settings 
    • I was going to see IF perhaps I could find a work around for the Blank space issue by adding a RegEX to the control itself...
Userlevel 5
Badge +14
  • Each individual control currently has not validation attached to them
    • I was going to see IF perhaps I could find a work around for the Blank space issue by adding a RegEX to the control itself...

You seem to be indicating that each control does not have validation set on it. If that is the case, do you just have (13) different rules all placed on a single control? Is that control the ReviewType control itself? If that's the case, how are you highlighting the controls that are 'invalid'? Either way, this approach could cause problems I'd imagine. 

Additionally, when you wrote the Rule were using the Item Property or the Named Control value from the Formula Builder? Selecting one over the other could cause all sorts of problems as the Item Property references the value of a Column in SharePoint as it is right now, while a Named Control references the value of the Form Control as named. 


Badge +5

Going to send Screenshots. 

Each "Option" has: 

  • Two formatting rules: 
    • One - Highlights the Control Name that is required 
    • The other - Hides the controls not necessary for the selection 
  • One validation rule: 
    • If RequestType == "ABC" then fill in the Required items (visually know by the control name being red)
  • The validation rules themselves are not necessarily tied to the individual controls but react using the RequestType 
    • So AvailableCapacity affected approx 9 controls 
    • Another Option may only affect 7, etc 
  • I am using the Named Controls in each instance 
    • "Selecting one over the other could cause all sorts of problems as the Item Property references the value of a Column in SharePoint as it is right now, while a Named Control references the value of the Form Control as named. "
Badge +5

ReviewType Options

Options for Review Type 

Rules

Home for all the Validations - Currently NONE on individual controls 

Badge +5

Non applicable fields

Non Applicable Fields 

Required Fields

Required Fields 

Required Fileds w Error

Required Fields not filled in - ERROR 

Userlevel 5
Badge +14

Interesting. 

I set up a test form with three 'ReviewType' options and a different rule (which was only on the ReviewType control), which allowed for three different configurations across its options. 

Everything worked the way that I would have expected it to with each option correctly invalidating the form if the control's required were not filled out. I have uploaded and attached my example form to this post

Due to how you have your own custom setup with your own custom javascript, I would highly recommend opening up the developer's console (using F12, use Chrome Browser if you can), and check to see if you are actually running into any errors anywhere in there which could prevent certain validation rules from being ran. 

Another suggestion would be to wrap your rule in a IIFE (Immediately Invoked Function Expression) like: 

(function() {
 
  var returnVal = (ReviewType == 'Option 1' && (isNullOrEmpty(trim(CustomerCompanyName)) ||
    isNullOrEmpty(trim(ResourceCenterDistrictLocation)) ||
    isNullOrEmpty(trim(StreetAddress)) ||
    isNullOrEmpty(trim(ZipCode)) ||
    isNullOrEmpty(trim(HourlyLoad)) ||
    isNullOrEmpty(HourlyLoadUnits) ||
    isNullOrEmpty(trim(DailyLoad)) ||
    isNullOrEmpty(DailyLoadUnits) ||
    isNullOrEmpty(trim(DeliveryPressurepsig))));

  console.log("Option 1 Evaluated to: " + returnVal);
  return returnVal
}())‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

In this way you can at least throw in a 'debugger;' statement or just see what's happening in the dev console. 

----------

Last but not least, I'd recommend to just break the rules up across the individual controls instead of trying to lump them all together at the topmost level, with a bunch of additional code to style them in a custom way unless it's absolutely necessary or you're hitting some type of crazy performance wall. 

The only other thing I could think of would be for you to just upload your form, or an example form (that is experiencing the same problem) to the forums for us to check out. 


Badge +5

"Last but not least, I'd recommend to just break the rules up across the individual controls instead of trying to lump them all together at the topmost level, with a bunch of additional code to style them in a custom way unless it's absolutely necessary or you're hitting some type of crazy performance wall. "

This would be almost impossible due to so many varying options (combinations). Each control has to go through: Enable/disable - Required/Not required - Optional - Multiplied by 13. And once I roll of the project; I have to think of someone else supporting this form.  

But I will take another option that is experiencing something similar and see if making the changes above help. I am honestly thinking this is partly due to an overload of rules ( I read this could possibly happen); there are a total of 41 rules. Because the other strange thing is it is it not happening to ALL of them. Only a select 3 or 4. 

Badge +5

Going to use this one to test for the time being. Same thing happening but I will keep this one in test.

This one has two review types.

ReviewType=='Pressure Related ' && MAOPReviewSubtype=='Preliminary' && (isNullOrEmpty(ResourceCenterDistrictLocation) ||
 isNullOrEmpty(trim(AffectedLineNumberName)) ||
 isNullOrEmpty(trim(DesignMAOPpsig)) ||
 isNullOrEmpty(trim(IR)) ||
 isNullOrEmpty(trim(AssignedProjectManager)) ||
 isNullOrEmpty(trim(SignedG3)) ||
 isNullOrEmpty(ApprovedHydroTestRecordsforAllFacilities) ||
 isNullOrEmpty(AsBuiltBOM) ||
 isNullOrEmpty(SubmittedEmergencySchematic) ||
 isNullOrEmpty(SCADAScreensApprovedActive) ||
 isNullOrEmpty(FacilitiesVerifiedin811Database))

Badge +5

Well I have narrowed it down to a couple things (No solution) 

  • Number one - the TRIM function Is the issue (but only for 3 of the 13) 
    • Remove the TRIM and the validation works
  • With the TRIM the trigger for failure is the FIRST item in the list. If it is filled out then there only needs to be a few of the remaining items populated and then the form can save
    • IF the first item in the list is not populated the validation works 

My code is not in custom Java (I am not proficient in Java) sad.png  It's just using the Rules Console *I am Sharepoint that had to learn Nintex by trial by fire (But a good thing; I like the product) 

I did open the Debugger - At a loss here. Nothing popped out but most of the code looked like it was all based on the form vs my specifics (does that make sense?) 

Unless I have an AH-HA moment I may have to compromise with these 3 for the time being. I have spent so much time and no clear "Why" has shown itself. I am sure it's there just not easily seen. 

Did I say THANK YOU for all of this? THANK YOU

I learned a few things i did not know.

Badge +5

I did my own testing since I know the issues. 

It is consistent where ever the TRIM is used. The key is filling in the FIRST item in the list. Then once some of the other are filled in it will save. QA missed because they were probably filling in randomly and it's easy to miss on the options that have smaller required fields. 

Badge +5

How do I upload a form ?

Userlevel 5
Badge +14

First, make sure that there is no information in your Form's Settings that might be sensitive (urls, names, etc.), and then export the Form as shown: 

218934_pastedImage_1.png

Here on the forums, instead of replying with the normal 'Quick' Editor, use the Advanced Editor option: 

218935_pastedImage_2.png

On this screen you should be able to see the area highlighted which will allow you to upload your form: 

218936_pastedImage_3.png

Badge +5

Done!

Userlevel 5
Badge +14

Finally had a chance to look at this during lunch. Nothing immediately popped out as problematic. I even used the rule how you had it written in the original topic post. 

Do you have a set of instructions that I can follow in which it will fail as it is failing for you? 


Badge +5

No real set of instructions. It was 100% random EXCEPT for the TRIM. so what I did in the meantime is juse remove the TRIM from all the validations and the forms works as they business wants. The TRIM was a way to solve the No-Space issue. I did find that an additional Regedit statement would do the job IF only I could get the right combo. I tried a few and the did "work" but not exactly how I wanted. sad.png 

They were restrictive but too much..but the correct error message came up to let me know it is possible. 

All I can think is that there may be something internally (system wise) causing the issue. 

Userlevel 5
Badge +14

Perhaps indeed. I am currently running SharePoint 2016 with the latest ver of Workflow and Forms. Tested with both the trim and non-trimmed versions and had the same results. The biggest issues that I noticed is that the form tends to deform as you make your selections that Hide / Show content, which, at least for me, would sometimes cause a few controls to be hidden behind others.  

Badge +5

What does " form tends to deform as you make your selections that Hide / Show content, which, at least for me, would sometimes cause a few controls to be hidden behind others.  " mean and how did you see it? 

We are on SP2013 and there are a lot of customizations. Not sure of the version of Workflow or Forms. I will "assume" the lastest but not sure. 

Userlevel 5
Badge +14

Here are a series of pictures showing the form from top to bottom. The highlighted area shows the problem in question. If you are not experiencing this in your environment, then I wouldn't worry about it. 

(Note that I have simply selected the top selection):

219059_pastedImage_1.png

219061_pastedImage_3.png
219063_pastedImage_5.png

Badge +5

Oh, ok. Not doing in my environment but interesting. 

Badge +5

I think the glitch must be system related BUT this exercise with you helped me to settle on a solution vs trying to go in circles fixing something that may not be immediately "fixable". 

Reply