I'm trying to figure out how to add two validation rules to One SharePoint list
-
21-01-2021 - |
문제
I'm trying to figure out how to add two validation rules to One SharePoint list.
- If the user selects 'Risk' from the 'Risk/Issue?' column, then they must not leave the 'Risk Mitigation Plan' field blank.
'Risk/Issue?' Column is a drop down menu, Risk Mitigation Plan is a multiple line text field
- If the user selects 'Closed' from the 'Status' column then the must not leave the 'Closed Date' field blank
The 'Status' field is a drop down menu and the 'Closed Date' field is a date picker
What formula would help me accomplish this? Thank you!
--I can change the field types if that helps
Screen shot of the list & validation I'm trying to Implement
해결책
Not sure if you're able to use js/jQuery but below is a way to accomplish this using code.
var status = $("select[title='Status']").val();
var closedDate = $("input[title='Closed Date']").val().length;
function PreSaveAction(){
if(status == "Closed" && closedDate == 0){
return False;
}
}
다른 팁
You cannot use multiline text in formula. If you can convert mitigation plan to a single line of text then below formula should work, assuming your other dropdowns fields are choice fields.
Navigate to List -> List Settings -> Validation Settings. Use below formula and add an appropriate error message in 'user message' field.
IF([Risk]="Risk",IF(NOT(ISBLANK([MitigationPlan])),TRUE,FALSE),IF([Closed]="Closed",IF(NOT(ISBLANK([ClosedDate])),TRUE,FALSE),TRUE))