Enable/Disable form control on activation of form D365 X++

Form : SalesQuotationListPage
DataSource : DH_SalesQuote
Event : Activated

[FormDataSourceEventHandler(formDataSourceStr(SalesQuotationListPage, DH_SalesQuote), FormDataSourceEventType::Activated)]
    public static void DH_SalesQuote_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        FormRun                  fromRunLoc;
        FormDataSource      formDataSourceLoc;
        DH_SalesQuote       SalesQuote;

        fromRunLoc            = sender.formRun();
        formDataSourceLoc   = sender.formRun().dataSource("DH_SalesQuote");
        SalesQuote               = formDataSourceLoc.cursor();

        if (SalesQuote.DH_DocumentWorkflowState == DH_DocumentWorkflowState::Completed)
        {
            fromRunLoc.control(fromRunLoc.controlId("FollowupStatus")).enabled(true);
            fromRunLoc.control(fromRunLoc.controlId("ButtonUpdateConfirmation")).enabled(true);
            fromRunLoc.control(fromRunLoc.controlId("UpdateQuotation")).enabled(true);
            fromRunLoc.control(fromRunLoc.controlId("Process")).enabled(true);
        }
        else
        {
            fromRunLoc.control(fromRunLoc.controlId("FollowupStatus")).enabled(false);
            fromRunLoc.control(fromRunLoc.controlId("ButtonUpdateConfirmation")).enabled(false);
            fromRunLoc.control(fromRunLoc.controlId("UpdateQuotation")).enabled(false);
            fromRunLoc.control(fromRunLoc.controlId("Process")).enabled(false);
        }
    }

Comments

Popular posts from this blog

On clicked event of form button in D365 X++

Finding unit price of item from trade agreement through code AX X++

Create Sales Line Through Code AX X++ D365 Finance & Operations