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.
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 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
- I was thinking of adding a RegEx component to the control itself but so far I am not able to make it work
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?
- 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...
- 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.
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. "
Options for Review Type
Home for all the Validations - Currently NONE on individual controls
Non Applicable Fields
Required Fields
Required Fields not filled in - ERROR
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.
"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.
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))
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) 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.
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.
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:
Here on the forums, instead of replying with the normal 'Quick' Editor, use the Advanced Editor option:
On this screen you should be able to see the area highlighted which will allow you to upload your form:
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?
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.
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.
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.
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.
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):
Oh, ok. Not doing in my environment but interesting.
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".