Sunday, 27 June 2021

D 365 FO Enable or disable & Mandatory or Non Mandatory based on Checkbox field using Extension Class

  [FormControlEventHandler(formControlStr(EcoResProductParameters, [FieldName]), FormControlEventType::Modified)]

    public static void [FieldName]_OnModified(FormControl sender, FormControlEventArgs e)

    {

        FormCheckBoxControl allowVehicleCreation = sender.formRun().design().controlName(formControlStr(EcoResProductParameters,[FieldName]));

        FormStringControl allowVehicleCreationGroup = sender.formRun().design().controlName(formControlStr(EcoResProductParameters,[FieldForWhichValidationRequired]));


        if(allowVehicleCreation.value() == NoYes::Yes)

        {

            allowVehicleCreationGroup.mandatory(true);

            allowVehicleCreationGroup.enabled(true);

        }

        else

        {

            allowVehicleCreationGroup.mandatory(false);

            allowVehicleCreationGroup.enabled(false);

        }

    }


Thank you

Keep Daxing :)

No comments: