D365F&O - X++ - Get formbuttoncontrol and multiple datasource records in onclicked eventhandler

[FormControlEventHandler(formControlStr(CostSheetCalculationFactor,
MassInventPriceCalcFactorActivateButton), FormControlEventType::Clicked)]
public static void MassInventPriceCalcFactorActivateButton_OnClicked(
FormControl sender, FormControlEventArgs e)
{
    #define.BUTTONNAME('MassInventPriceCalcFactorActivateButton')

    CostSheetCalculationFactor              costSheetCalculationFactorLocal;
    MultiSelectionHelper                    selectionHelper =
                                            MultiSelectionHelper::construct();
    boolean                                 enableActivateButton = true;
   
    selectionHelper.parmDataSource(sender.formRun().dataSource(1));

    costSheetCalculationFactorLocal = selectionHelper.getFirst();

    while (costSheetCalculationFactorLocal)
    {
        if (!costSheetCalculationFactorLocal.allowActivate())
        {
            enableActivateButton = false;
            break;
        }
        costSheetCalculationFactorLocal = selectionHelper.getNext();
    }
    FormButtonControl ButtonControl = sender.formRun().design().controlName(
                                        #BUTTONNAME);
    ButtonControl.enabled(enableActivateButton);
} 

Comments

Popular posts from this blog

D365F&O - X++ - Best Practice Warning BP Rule: [BPErrorUnknownLabel]: Path:

D365F&O - X++ - How to Enable/Disable button on form based on a condition in D365F&O using Event handlers.

D365FO - X++ - Generate CAR (Customized Analysis Report) report of custom model