Search code examples
validationsharepoint-2010

How to conditionally require 18+ fields based on selection of two dropdowns


I'm new to Sharepoint 2010 with what I would call a highschool freshman level of coding experience, though I can generally stumble and tinker my way through. I don't currently have access to Sharepoint designer, but from the searching I've done so far, it may required. Still I'm hoping to find an OOTB solution to the problem below.

I have been tasked with building a incident resolution tracking sheet on Sharepoint. My boss is very concerned with being audited by legal, and has some very specific requirements about required information. Column A contains a drop down list of 5 choices that indicate the Final Solution. Column B Contains a drop down list with 4 choices that indicate the Initial Problem. Based on The selections in A and B, different Columns in C-X are required to be blank, not blank, or contain specific entries. The only way I can find to do this is to create a list validation containing a nested if for each combination of A and B resulting in 20 nested ifs. However sharepoint is limited to 7 nested ifs, so I'm looking for any possible solutions.

*This List will primarily be accessed in Datasheet view, so "HTML in calculated column" type solutions are not viable.


Solution

  • You can use calculated columns to break up the validation formula into more manageable chunks.

    Let's start with a simple example.

    Condition 1: If the initial problem was that the user's computer was too slow and the final solution was restarting the computer, you need to fill in the [C] column.

    Condition 2: If the initial problem was that the user was on fire and the final solution was dousing them with water, you need to fill in the [D] column.

    You could perform that list validation all in one formula, as below:

    =IF(
        AND([A]="Restarted Computer",[B]="Computer is slow"),
        NOT(ISBLANK([C])),
        IF(
            AND([A]="Doused with water",[B]="User is on fire"),
            NOT(ISBLANK([D]),
            TRUE
        )
     )
    

    But that's long and ugly (especially when you condense it to one line).

    Instead, you could add two calculated columns, one for each condition you want to check. For the sake of this example, let's say you add a column called C_is_valid and a column called D_is_valid:

    C_is_valid calculated column formula:

    =IF(AND([A]="Restarted Computer",[B]="Computer is slow"),NOT(ISBLANK([C])),TRUE)
    

    D_is_valid calculated column formula:

    IF(AND([A]="Doused with water",[B]="User is on fire"),NOT(ISBLANK([D]),TRUE)
    

    Updated validation formula:

    =AND([C_is_valid],[D_is_valid])
    

    It's easy to see how this can simplify even a very complex set of validation conditions...

    =AND(C_is_valid,AND(D_is_valid,AND(E_is_valid,AND(F_is_valid,AND(G_is_valid,AND(H_is_valid,I_is_valid)))))
    

    But even that could be simplified by consolidating some of those AND()s into multiple calculated columns, so that your final validation formula could be as simple as:

    =AND([First set of conditions is valid],[Second set of conditions is valid])