如何检查是否选择了选择字段选项

How to check if a Choice field option is selected

在我们的 PowerApps 表单中,我们的提交按钮的 DisplayMode 由检查所有必填字段已完成的公式确定。

If (
    And(
        Or(DPIAForm.Mode=FormMode.Edit,DPIAForm.Mode=FormMode.New),
        Not IsBlank(TitleField.Text),
        Not IsBlank(DescOfInitiativeField.Text),
        DateRaisedField.SelectedDate <> Date(
            1900,
            01,
            01
        ),
        Not IsEmpty(PersonalDataChoiceField.SelectedItems.Value),
        Not IsEmpty(SpecialCatChoiceField.SelectedItems.Value),
        Not IsEmpty(ChildrensDataChoiceField.SelectedItems.Value),
        Not IsEmpty(CriminalChoiceDataField.SelectedItems.Value),
        Not IsEmpty(SourcesOfDataChoiceField.SelectedItems.Value),
        Not IsEmpty(NumberOfIndividualDataSubjectsChoiceField.SelectedItems.Value),
        Not IsEmpty(LawfulBasisChoiceField.SelectedItems.Value),
        Not IsBlank(ProviderField.Text),
        Not IsEmpty(NewTechnologyChoiceField.SelectedItems.Value),
        Not IsEmpty(DataEvaluatedOrScoredChoiceField.SelectedItems.Value),
        Not IsEmpty(DecisionsMadeAutomaticallyChoiceField.SelectedItems.Value),
        //Not IsBlank(KindofDecisionsMadeAutomaticallyField.Text),
        If(DecisionsMadeAutomaticallyChoiceField.SelectedItems.Value ="Yes", Not IsBlank(KindofDecisionsMadeAutomaticallyField.Text), "" ),
        Not IsEmpty(IndividualNotAwareOfPersonalDataCaptureChoiceField.SelectedItems.Value),
        Not IsEmpty(DataTransferredOutsideEEAChoiceField.SelectedItems.Value),
        Not IsBlank(WhoWillHaveAccessToDataField.Text),
        Not IsEmpty(MonitoringIndividualsChoiceField.SelectedItems.Value),
        Not IsEmpty(CriminalChoiceDataField.SelectedItems.Value),
        Not IsEmpty(MonitoringIndividualsChoiceField.SelectedItems.Value),
        Not IsEmpty(DataRetentionPlanChoiceField.SelectedItems.Value),
        Not IsBlank(RetentionPlanForPersonalDataField.Text),
        Not IsBlank(RetentionPlanForSensitiveDataField.Text),
        Not IsBlank(RetentionPlanForChildrensDataField.Text),
        Not IsBlank(RetentionPlanForCriminalConvictionDataField.Text),
        Not IsEmpty(SupplierDueDiligenceDoneChoiceField.SelectedItems.Value),
        Not IsEmpty(GDPRCompliantContractWithAll3rdPartiesChoiceField.SelectedItems.Value),
        StatusDataField.Text = "Draft"
        ),
    DisplayMode.Edit,
    DisplayMode.Disabled)

我们遇到麻烦的部分是中间的公式:

    If(DecisionsMadeAutomaticallyChoiceField.SelectedItems.Value ="Yes", Not IsBlank(KindofDecisionsMadeAutomaticallyField.Text), "" ),

这里我想测试一下,如果用户在drop-down/choice字段ecisionsMadeAutomaticallyChoiceField中选择了"Yes",如果是,那么KindofDecisionsMadeAutomaticallyField字段一定不能是blank/empty 以便启用 提交 按钮...

但我在 If(DecisionsMadeAutomaticallyChoiceField.SelectedItems.Value ="Yes"

上收到错误 参数类型无效

我也试过:

If(DecisionsMadeAutomaticallyChoiceField.SelectedItems(1)

那么在我们的公式中正确的做法是什么?

我发现答案是通过以下方式检查是否被选中:

if("Value" in ComboBox.SelectedItems.Value, 
Not IsBlank(TextDataField.Text), IsBlank(TextDataField.Text) ),

所以在我的例子中正确的公式是:

if("Yes" in DecisionsMadeAutomaticallyChoiceField.SelectedItems.Value, 
Not IsBlank(KindofDecisionsMadeAutomaticallyField.Text), 
IsBlank(KindofDecisionsMadeAutomaticallyField.Text) ),