SBX - Search With Button

SBX - Forum Post Title

Disable RunBase Dialog On Runtime

Dynamics 365 for Finance and Operations Forum

Sona Jee asked a question on 14 Jun 2019 4:50 AM
My Badges

Question Status

Verified

Hi Experts

I have a RunBase class with two fields as following:

I want to disable one field i.e Customer id when we select value in customer account field.

For this i have added this code:

class TestDialog extends RunBase
{    
    DialogField             fieldCustomerAccount;
    DialogField             custId;
    CustTable               custTable;
    CustAccount             account;  

 
    public Object Dialog()
    {
        Dialog  dialog;
        FormBuildStringControl          formStrCtrls;

        dialog = super();       
        dialog.caption("Test");        
        fieldCustomerAccount = dialog.addField(extendedTypeStr(CustAccount), "Customer account" );
        custId = dialog.addField(extendedTypeStr(String10), "Customer id" );        
        formStrCtrls             = custId.control();        
        formStrCtrls.registerOverrideMethod(methodStr(FormStringControl, modified), methodStr(TestDialog, modified), this);

        return dialog;
    }

    public boolean getFromDialog()    {
        
        account  = fieldCustomerAccount.value();
        return super();
    }

    protected boolean canRunInNewSession()
    {
        return true;
    }

    static TestDialog construct()
    {
        return new TestDialog();
    }

    public static void main(Args _args)
    {
        TestDialog testDialog = TestDialog::construct();
       
       
        if (testDialog.prompt())
        {
            testDialog.run();
           
        }
    }

    public void modified(FormStringControl _control)
    {
        if(fieldCustomerAccount.value())
        {
        
            custId.enabled(false);
        }
    
    }

}

But it did not work.

Please suggest how to disable dialogbox.

Thanks

Sona Jee

Reply
Verified Answer

If you want to disable customer ID then you need to registerOverrideMethod for fieldCustomerAccount , because currently your code overrides custId. So, instead of

formStrCtrls = custId.control(); 

write

formStrCtrls = fieldCustomerAccount .control();  
Reply
Sona Jee responded on 15 Jun 2019 1:38 AM
My Badges

Hi ievgen Miroshnikov

It works for me.

Thank you

Reply
Verified Answer

If you want to disable customer ID then you need to registerOverrideMethod for fieldCustomerAccount , because currently your code overrides custId. So, instead of

formStrCtrls = custId.control(); 

write

formStrCtrls = fieldCustomerAccount .control();  
Reply

SBX - Two Col Forum

SBX - Migrated JS