1

I have a requirement with SharePoint List to have to option with Yes or No Column or a choice. If the Choice is NO (Nothing to be done)

IF the Choice is Yes (then i need 3 options) like -

  1. End of Day
  2. High priority
  3. Fill able Date (DD/MM/YYYY)

Any help will be appreciated. Thank you.

Need to get this done using out of box. In the new/edit form.

3 Answers 3

1

We can create a Yes/No column "YesNo", and create three columns "End of Day","High priority" and "Fill able Date". Then add the code below into a script editor web part into new/edit form page. If yes/no column choice "Yes", those three columns show, if choice "No", hide those columns.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
    var yesNoFieldName="YesNo";
    var optionFields=["End of Day","High priority","Fill able Date"];
    if($("input[title='"+yesNoFieldName+"']").is(':checked')){
        showFields(optionFields);
    }else{
        hideFields(optionFields);
    }
    $("input[title='"+yesNoFieldName+"']").change(function(){
        if($(this).is(':checked')){         
            showFields(optionFields);
        }else{
            hideFields(optionFields);
        }
    });
})
function hideFields(optionFields){
    for(var i=0;i<optionFields.length;i++){
        $(".ms-standardheader:contains('"+optionFields[i]+"')").closest("tr").hide();
    }
}
function showFields(optionFields){
    for(var i=0;i<optionFields.length;i++){
        $(".ms-standardheader:contains('"+optionFields[i]+"')").closest("tr").show();
    }
}
</script>
0
0

I am assuming that you want some sort of validation based on yes/no check box and 'End of Day' and 'High Priority' are choices in a dropdown. If yes then you try below steps.

Create a yes/no column, a choice column with choices 'End of the Day', 'High Priority', a date column. Then navigate to list settings -> Validation settings and use below formula to ensure form performs validation at all times. In below formula 'YesNo' is a yesno column name, ChoiceCol is Choice column name and DateCol is date column name.

=IF(YesNo=TRUE,IF(ISBLANK(ChoiceCol),FALSE,IF(ISBLANK(DateCol),FALSE,TRUE)),TRUE)

The above formula invalidates the form if the Yes/No column is true and either the dropdown and date column is blank. You can always use field description field to provide explanation on when to use a particular field (as we are not showing/hiding any fields here)

Alternatively you can always use some javascript on the forms to perform validation and show/hide fields based on user input.

0
0

Another way could be to use a managed metadata column with options yes and no, and a branch with additional options under No.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.