web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

extension of the standard form updatedesign()

(3) ShareShare
ReportReport
Posted on by 1,274
Hello,
 
I have added a custom control LogisticsPostalAddress_WarehouseOnly to the standard form LogisticsPostalAddress by means of the form extension. Then I'd like to extend the standard form method updateDesign() like that
 
1st approach
 
​

[ExtensionOf(formstr(LogisticsPostalAddress))]
public final class LogisticsPostalAddressForm_Extension
{
    public void updateDesign()
    {
        FormBuildDesign formBuildDesign = this.form().design();
        FormBuildCheckBoxControl wareHouseOnlyCBCtrl;

        wareHouseOnlyCBCtrl = formBuildDesign.control('LogisticsPostalAddress_WarehouseOnly');

        next updateDesign();

        switch (callerTableId)
        {
            case tableNum(CustTable):
                wareHouseOnlyCBCtrl.visible(true);
                break;
        }
    }

}


​
 
2nd approach. I put Autodeclaraton property of my custom control to Yes
​

ExtensionOf(formstr(LogisticsPostalAddress))]
public final class LogisticsPostalAddressForm_Extension
{
    public void updateDesign()
    {
        next updateDesign();

        switch (callerTableId)
        {
            case tableNum(CustTable):
                LogisticsPostalAddress_WarehouseOnly.visible(true);
                break;
        }
    }

}


​
 
IN the 1st approach on this line I get null object reference on this line  because control object wareHouseOnlyCBCtrl doesn't come. It's null. It's not fetched. formBuildDesign object is initialised and looks good.
 
wareHouseOnlyCBCtrl = formBuildDesign.control('LogisticsPostalAddress_WarehouseOnly');
 
the same goes with 2nd approach
 
How can I fix this please or what I'm mixing up?
 
Thank you.
I have the same question (0)
  • Verified answer
    Waed Ayyad Profile Picture
    9,133 Super User 2026 Season 1 on at
     
    Try the following code:
     
    [ExtensionOf(formstr(LogisticsPostalAddress))]
    public final class LogisticsPostalAddressForm_Extension
    {
        public void updateDesign()
        {
    
            FormRun formRun = this; 
    
            FormCheckBoxControl  wareHouseOnlyCBCtrl = formRun.design().controlname(formControlStr(LogisticsPostalAddress, YourCheckBoxName)) as FormCheckBoxControl ;
    
            next updateDesign();
    
            switch (callerTableId)
            {
                case tableNum(CustTable):
                    wareHouseOnlyCBCtrl.visible(true);
                    break;
            }
        }
    
    }

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Verified answer
    Martin Dráb Profile Picture
    239,399 Most Valuable Professional on at
    Referring to the control by name is much simpler (and it doesn't even need Auto Declaration) and safer, therefore I don't see any reason why you would like to use the complicated approach with FormBuildDesign.
     
    Note that each of your examples uses a different control name - which one is correct? Maybe using a wrong name is your actual bug.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 657

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 615 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans