Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

How to hide form parts

(2) ShareShare
ReportReport
Posted on by 522
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?
  • Layan Jwei Profile Picture
    Layan Jwei 7,349 Super User 2024 Season 2 on at
    How to hide form parts
    Hi,

    Is your question answered? if yes then please verify the answers that helped
  • Layan Jwei Profile Picture
    Layan Jwei 7,349 Super User 2024 Season 2 on at
    How to hide form parts
    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
  • AG-10050919-0 Profile Picture
    AG-10050919-0 7 on at
    How to hide form parts
    @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!
  • Suggested answer
    Kevin Xia Profile Picture
    Kevin Xia Microsoft Employee on at
    How to hide form parts
    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
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,349 Super User 2024 Season 2 on at
    How to hide form parts
    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
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,391 Super User 2024 Season 2 on at
    How to hide form parts
    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.  

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans