How to check more than 5 fields under action rule condition in infopath 2010 - infopath2010

I am working on an infopath 2010 form/view based on a list.
I have 7 separate check box fields that I want to check through a rule under submit button that at least one of them should be selected.
Trying to do this and check for the condition, it is allowing me to check a maximum of 5 fields at a time.
How can I check at least one of these 7 check boxes is selected before submitting the data?

You can overcome this by changing your last condition to "The expression" and use "and" or "or" as needed to create your compound condition. So, for example, if you need to make sure both field1 and field2 are not blank, you'd use the expression:
my:myFields/my:field1 != "" and my:myFields/my:field2 != ""
If you need help figuring out the correct syntax for your expression, first set up the condition using the drop downs (for example, select field1 in your first drop down, then "is not blank" in your second drop down), then change the first drop down to "The expression" -- whatever your condition was will auto populate into the box for the expression. Paste that into a text editor, and then do the same for the rest of your conditions. Add and or or between them as needed, and you have your expression!
Source: http://www.infopathdev.com/forums/p/14871/52819.aspx

I had a similar issue and avoided using "The Expression" option because I had so many conditions to check before allowing a user to submit the form for certain scenarios, and it would have been very tough to debug and troubleshoot. I also considered Glen's sum-based solution because it made troubleshooting difficult as you can't really tell which condition is missing, and you can't perform logical checks on what's been selected or filled-in properly.
My solution was to set up a text CheckStatus field and a numeric CheckStatus-Value field. Rules on tested fields would add values to the CheckStatus field when the needed conditions were met. And when the CheckStatus-Value field hit the “magic number” (6 in the example below), then I would allow the user to submit the form. As an example, the CheckStatus-Value and CheckStatus fields are shown below, but would be hidden when the form is ready for production use:
CheckSum-Value & CheckSum fields
Then for every desired field, I assign a unique letter from “A” to “Z”, or from “a” to “z”, or from “0” to “9”, and test for the desired condition. In this way you could test for up to 62 concurrent conditions, tho that would be a bit crazy 😊 Every time the CheckStatus field changes, a rule runs to count the number of values and update CheckStatus-Value:
Update CheckSum-Value field
IF the condition is True AND the CheckStatus field does not already contain the unique letter/number assigned to that field, then I add the assigned number/letter (using the concat function) to the CheckStatus field. If a blank value is a valid value under specific conditions then I add the letter/number for the field when that condition is met, so a ready-to-submit form always has the same value in the CheckStatus-Value field. (If a valid value is changed to a different valid value, ensure the letter/number is only added ONCE to the CheckStatus field.)
Add value A to CheckStatus field
 
IF the condition is False, then I remove the assigned number/letter (using the translate function) from the CheckStatus field.
Remove value A from CheckStatus field
IF the field being tested (Field-A) is dependent on another field (Field-B), I also add the Field-A rule to Field-B, so the user does not have to touch Field-A to update the CheckStatus. Be careful when copy-pasting the rules; remember InfoPath will change field names automatically! I also added the “’Add-x”’ rules to the Form Load rules (on the Data tab) to update CheckStatus every time the record is loaded.
Hope this helps!
-Steve

Here's an idea: Use an integer field and put a rule on each of your 7 checkboxes that adds 1 to the field. Then your final validation rule just needs to be sure the integer field is greater than zero
(Better also have a rule to subtract 1 if a box is unchecked after being checked.)
-Glen

Related

When one field doesn't equal another field then show a completely different field

First time asking a question and have learned a lot from this forum. I work in a weird industry and we are using NetSuite. I am having a hard time coming up with a criteria or formula for what I am trying to do. On any sales order we have the Business Source who could be the listing agent or the selling agent for a property. The business source is not always the listing agent or always the selling agent. So I am trying to do a search where (excuse the bad coding example):
If business source is the listing agent, then show the selling agent
If business source is the selling agent, then show the listing agent
From a sales perspective, we want to reach out to the other agent, even if they didn't direct the order our way, and thank them for working with us.
I hope I was somewhat clear...and thanks in advance!
Add a line in the Results tab and select Formula (text) under the Field column. In the Formula column add:
CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} ELSE {custbody_listing_agent} END
You will need to replace the fields in braces {} with the correct IDs for the fields you're using. I have assumed that these fields all pull from the same list of records (contacts or customers) for the information they contain. It probably won't work, for example, if one is a select (List/Record) field and the others are Free Text. This simply compares the Business Source field with (arbitrarily) the Listing Agent and returns the Selling Agent if there's a match, otherwise it returns the Listing Agent. Note that this means the Listing Agent will be returned in any other circumstances also; for example if one of the compared fields is empty.
You could match the Business Source against both the agent fields explicitly and return some other value when neither match by extending the CASE statement a little:
CASE WHEN {custbody_business_source} = {custbody_listing_agent} THEN {custbody_selling_agent} WHEN {custbody_business_source} = {custbody_selling_agent} THEN {custbody_listing_agent} ELSE {somethingelse} END
or by using a DECODE instead:
DECODE({custbody_business_source}, {custbody_listing_agent}, {custbody_selling_agent}, {custbody_selling_agent}, {custbody_listing_agent}, {somethingelse})
DECODE has the following signature:
DECODE({expr}, search, result, [search, result]..., [default])
It compares expr with each search value one by one. If it finds a match it returns the corresponding result. If no match is found, the default is returned, or null if default is not specified.

Multi LookUp - Check for unique values

I´m trying to set up unique values in my PowerApp-Form. The data is stored in a Sharepoint list. I have a column called watches, items in this column have a unique number, which have to be unique. People can pick multiple of those watches in a LookUp-field. But before submitting the form, I need to check if those picked values already exist in my list and at least display an error message.
I have setup a regular text field and added following rule to it:
If(LookUp(MyList.Watches;DataCardValue4.SelectedItems.Value in Watches;"OK")<>"OK";"No Error";"Watch already exist")
DataCardValue4 is my LookUp field, where people can pick those watches. With this rule I want to check if a item already is in my column watches and let my text field display the error. Somehow the rule doesn´t work.
Can you tell me how I compare multiple lookup choices to my table/column entries?
The first parameter to the LookUp function should be the table (SharePoint list) rather than the column. So the first parameter should be 'MyList' rather than 'MyList.Watches'. Also, I'm not sure that the formula provided (second parameter to LookUp) will work. In your formula, you will be looking for multiple items (DataCardValue4.SelectedItems.Value) within multiple items (Watches). Perhaps you can update your app to have users only pick one watch value before submitting?
One last thing to note. I'm not sure how big you expect your SharePoint list to get, but I would highly recommend keeping your LookUp formula within the bounds to support delegation. More specifically, SharePoint has different formula requirements than other connectors. For example, you can use '=' in your formula, but not 'in'.
Your new rule might look something like below. Please note that it could have syntax errors and might not even be delegable in it's current form since I am providing the rule with no checking. Also, I switched from using LookUp to using Filter instead just because I'm more familiar with Filter. However, both functions are very similar.
If(CountRows(Filter(MyList; DataCardValue4.Selected.Value = Watches)) > 0; "Watch already exist"; "No Error")

Saving SharePoint list item as draft without required fields

E.g. there is a list with gazillion required fields and I want the users to be able to fill out whatever they can and save as a draft until they have full info? Is there a simple solution for this? Tia!
Option 1: Multiple Content Types
One approach is to have two different Content Types on your list: one for draft items and one for submitted ones.
Content types on the same list can have different settings for the same columns. This means you can make the fields optional on the "draft" content type while making them required on the "submitted" content type.
The downside is that it may not be intuitive for end users if they're required to manually change the "Content Type" field in order to publish their draft.
Option 2: List Validation Settings
Another approach is to use List Validation settings instead of making fields required.
List validation lets you specify an Excel like formula (from which you can reference column values) which must evaluate to true in order for the validation to succeed. If it evaluates to false, a validation error message is displayed instead (you can specify the text of that message) and the item cannot be saved.
Simplified Scenario: One Field
Suppose you have a field called First Field that you don't necessarily need to be filled out right away, and you also have a choice field called Status Field that's used to indicate whether an item is a draft version or is submitted (displaying either "Draft" or "Submitted").
You can set up a list validation formula that requires First Field to be filled in whenever the Status Field is changed to "Submitted".
The formula would look like this:
=If([Status Field]="Submitted",NOT(ISBLANK([First Field])),TRUE)
In plain English, that formula is saying:
If Status Field is equal to Submitted...
...Then the form is valid only if First Field is not blank.
Otherwise, the form is valid.
More Complex Scenario: Multiple Fields
To make that work for multiple fields, you can join conditions together using the OR() and AND() functions, in the format of OR(condtion1,condition2)
So instead of ISBLANK([First Field]) to check whether a field is blank, you'd have something like OR(ISBLANK([First Field]),ISBLANK([SecondField])) to check whether either of two fields is blank. (Replacing First Field and Second Field with your field titles as appropriate.
The formula would now look like this:
=If([Status Field]="Submitted",NOT( OR(ISBLANK([First Field]),ISBLANK([Second Field]))),TRUE)
Note that you can nest multiple OR() conditions together arbitrarily, in the format of OR(condition1, OR(condition2, OR(condition3, condition4))) (and so on indefinitely).
Offloading Formula Complexity to Calculated Columns
If you run into limits with the formula length, you can offload some of your condition calculations into their own calculated columns, then just refer to those column values from your validation formula.
This can also help keep your formula from looking so complex.
For example, for every field that you want to be required, you can create a calculated column with a formula of =NOT(ISBLANK([Column Name])) and name it something like "{Column Name} Is Valid". Then you can refer to those columns in your validation formula:
=If([Status Field]="Submitted",AND([Field1 Is Valid],AND([Field2 Is Valid],[Field3 Is Valid])),TRUE)

In a Notes field with a dialoglist, how can I display a blank as "None" for example?

I have a field where Yes and No are the valid selections in the dialoglist, the valid values for the field are setup with Synonyms like this Yes is Y and No is an empty value/blank/nothing.
Yes|Y
No|
When the document is saved this the field selection of "No" and re-opened how can I get the form field to display the word "No" when the field is blank?
It's not possible to accomplish that just with an alias definition.
You could work with two fields to get an empty field for "No":
Your current field let's say "TestUI" of type dialog list would have the choises
Yes|Y
No|N
and an additional computed text field "Test" with the formula
#Replace(TestUI; "N"; "")
would replace the "N" with an empty string.
You can avoid the two field solution by using a PostOpen formula:
FIELD MyDialogList := #If(MyDialogList="";"No";MyDialogList);
#All
P.S. I'm not sure what your intention was here, but this is actually not a bad way to deal with the case where you're adding a new field to an old form and you don't want to have to run an agent to add the new field to all previously saved documents. Since formulas just treat missing fields as empty strings, the #If will work as expected.
It seems like you've run into an edge case and you probably will need to assign some value as the alias to "No".
If it is really important to have the value be blank when a user selects No, you could create a second computed field that maintains the alias values. Assuming your dialog list field is called "YesNo", your computed field's formula could be:
#If(YesNo = "Yes"; "Y"; "");

Select all used values of a specific field as source for dialog list choices

In my Lotus Notes Database, I want to fill the choices available in a dialog list based on the previously entered values for this field.
I set type of the field to "Dialog list", chose "Use formula for choices" and selected "Allow values not in list".
However, I don't know what to enter as a formula:
The formula's result should be all values for the field Foo specified in the database.
I tried the following formula which results in an empty list, however:
#Unique(SELECT Foo)
There are definitely documents with values for Foo in the database.
Which formula can I use?
Or do you know better solutions to my problem than using a formula?
Many thanks in advance for your responses!
You need to create a view with at least a column that displays the Foo field. You can then use #DbColumn in your formula to retrieve all values from e.g. column 1 containing the Foo field:
#Unique(#DbColumn("";"":"database.nsf";"Your new view";1))
Here is more informatiom about #DbColumn: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.main.doc%2FH_GENERATING_CHOICES_FOR_LISTS_STEPS.html
Similar way, but error handling included.
Look := #DbColumn("":""; ""; "$LookFoo"; 1);
#If(#IsError(Look); ""; #Unique(Look))
Database parameter can be empty, if you are reading from the current. If there is a problem with cache, you can make first parameter like - #DbColumn("":"NoCache";...
Hope it helps.

Resources