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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

extension of the standard form updatedesign()

(1) ShareShare
ReportReport
Posted on by 909
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_WOOM = 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_WOOM.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)
  • Suggested answer
    Waed Ayyad Profile Picture
    8,879 Super User 2025 Season 2 on at
    extension of the standard form updatedesign()
    Hi,
     
    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 878 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 681 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 496 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans