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 :
Microsoft Dynamics CRM (Archived)

Hide sections in crm form based on certain conditions

(0) ShareShare
ReportReport
Posted on by 7,316

Hi,

Can anyone help me with this scenario.

How can I hide few sections(one or more) in a form based on certain dynamic conditions like

1. for a particular logged in user

2. if the user's name is in exclusion list

3. and also if this user searches for the section in the Advanced Find.

I am trying to write JavaScript for this and I want to know your suggestions, so I can follow them as well.

Thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi, I try to give you step and clue

    1. DO you mean want to filter based on security role of the logged in user or by a custom list of user + security role. If you need list, then, you should create a custom entity as list.

    2. If you use security role, there are bunch of javascript code published in the internet, this is one of them:

    rajeevpentyala.wordpress.com/.../check-user-role-in-crm-2011-using-jscript

    and this is

    www.infinite-x.net/.../retreiving-user-roles-in-crm-2011

    but, if you use custom list, then you should write javascript to read the custom list, to check this user is in the existing list or not. Or, for easier way, in the user master, why you dont create a field to store yes or no access.

    3. and also if this user searches for the section in the Advanced Find. --> I dont understand what section do you refer in Advanced Find?

    As far as I know, section is in under form, so it means that whatever it comes from, from Gridview or advanced find should open the same form, and there is will be only section in form. This is that I dont understand and you make me confused about telling section + adv find.

    this is the javascript to hide section:

    To show a section :

    Xrm.Page.ui.tabs.get("yourtabname").sections.get("your section name").setVisible(true);

    To hide a section:

    Xrm.Page.ui.tabs.get("yourtabname").sections.get("your section name").setVisible(false);

    So, by combine javascript from 1 and 3, you should achieve this.

    Hope it helps!

    Thanks.

  • meenoo Profile Picture
    7,316 on at

    Thanks Aileen,

    Yeah you made me realize its the same thing however(search in Advanced Find).

    So I regarding the user role, my users will be selected from the lookup and I need to make sure that if the user selected from the lookup and logged in user is same then few sections should be invisible to that user.

    I've written accordingly, if you can look at this code and let me know if this is the way.

    function hideSectionOnLoad(){

    Xrm.Page.getAttribute("new_memberexclusion").addOnChange(onMyLookupChange);

    }

    function onMyLookupChange(){

    var lookupField = new Array();

        lookupField = Xrm.Page.getAttribute("new_memberexclusion").getValue();

        if (lookupField != null)

        {

            var name  = lookupField[0].name;

            var guid  = lookupField[0].id;

            if (name == Xrm.Page.context.getUserName())//here I want to see if the logged in user is in exclusion list

    {

                 Xrm.Page.getControl(" ").setVisible(false);//I am stuck here how to proceed?

            }

        }

    }

    Setting the sections hide depends on the form owner who can assign different entities(sections) that he want to hide from the user.

    Those entities are 5 and need to check those entities and set the sections 'hide' accordingly.

    how can I proceed? please help me..

  • meenoo Profile Picture
    7,316 on at

    Hi Aileen,

    Yes I am going to check on user security role and see if this user is the logged in user and if his name is in the exclusion list(this is lookup field).

    And just curious what do you mean by this?

    Or, for easier way, in the user master, why you dont create a field to store yes or no access.

    Can you explain a bit more of custom list?

    Thank you

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Dasu,

    That I mean custom list, you said exclusion list, it means stored in another list (another entity)

    My suggestion is just store in the System User entity and create a field Exclude or Include.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans