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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to hide form parts

(2) ShareShare
ReportReport
Posted on by 534
Hi Guys,
 
In forms design next to data-source we have /Parts/ where we will add the form display menu item so that we will get that form in related information pane.
 
My question here is can I able to hide it based on the conditions using code?
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,109 Super User 2025 Season 2 on at
    Hi Community user,

    Can you tell what exact conditions you have in mind? If it is related to users, then you can use the security framework by not granting access to the form part. In case the condition is related to country specific features, you can use the country/region property on the menu item.
    I haven't checked myself if you can hide the form parts using x++. At least, you can hide form controls, in coding by setting the visible property to no.  
  • Suggested answer
    Layan Jwei Profile Picture
    8,118 Super User 2025 Season 2 on at
    Hi Community User,

    This is how you can try to hide FormPart by code, try it please and let's us know if it works.  (not sure what your conditions are but you can add them in the code below)

    [ExtensionOf(formStr(Formxx))]
    final class Formxx_Extension
    {
        public void init()
        {
            next init();
    
            partList = new PartList(this);
     
    
            for (int i = 1; i <= partList.partCount(); i++)
            {
                FormPartReferenceControl part = partList.getPartControlById(i);
                if (part.formName() == formStr(Formyy))// this is the name of the form that is linked to displayMenuItem and not the formPart name
                {
                    part.visible(false);
                }
            }
            
        }
    }
    


    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Suggested answer
    Kevin Xia Profile Picture
    Microsoft Employee on at
    Hi,
    As Andre said, you can start by thinking about hiding menu items through settings, not code, because code involves custom development. You can do this by setting security roles, or by applying the country/region context. This is the official documentation on applying the country/region context: Apply country/region context - Finance & Operations | Dynamics 365 | Microsoft LearnIn this article you can find information how you should use country context property and what application objects control user interface elements.
    Best regards,
    Kevin
  • AG-10050919-0 Profile Picture
    7 on at
    @Layan Jwei how to put this code into Dynamics? What application is needed? Can I do it by VisualStudio?
    What if a Microsoft partner did customizations that I don't have access to? Can it be a blocker?
    Thank you!
  • Layan Jwei Profile Picture
    8,118 Super User 2025 Season 2 on at
    Hi Anna,

    Yes you need Visual studio to add this customization.

    If it's a standard form, then you need to create a class and add the code i showed you.

    If the form relates to a Microsoft partner, does your model references it? then you can create also the class and add the code i showed you. If not, then you will need to ask them to add the code for you. Or you can create a new model that references them and add the code yourself.

    it depends on your situation. 

    if the code works, then please verify the answers that helped you.

    Thanks,
    Layan Jweihan
  • Layan Jwei Profile Picture
    8,118 Super User 2025 Season 2 on at
    Hi,

    Is your question answered? if yes then please verify the answers that helped

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans