Javascript code for hiding sections in the form RRS feed

  • Question

  • Hi,
    I am trying to write a javascript code for hiding few sections based on certain conditions.
    I have a section in the main form with a subgrid.This section is for entering users to the exclusion list.(below picture is the subgrid opened)
    So whoever will be in this list should not be able to see few sections in the main form.

    The sections to hide will be entered in the entity exclusion list and they are not all required.

    So there can be only one entity or all entities(or sections).

    My code what I've written so far.. but I am completely stuck at the point how to retrieve the entity lists that have to be hidden.

    Can someone please look into it and let me know..

    function hideSectionOnLoad(){

    function onMyLookupChange(){
    var lookupField = new Array();
    = 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?


    Also is it possible to customize Advanced Find for this purpose if user searches for these sections in Advanced FInd, he should not be able to look at them from here as well. Can this be done?

    Thank you in advance.

    • Edited by ReignFan Saturday, July 26, 2014 8:31 PM None
    Friday, June 27, 2014 9:01 PM

All replies

  • Hi,

    Try this:


    Found it here:



    Friday, June 27, 2014 10:06 PM
  • Thank you.

    But how can I select the entities in 'Entity Exclusion' and hide the sections accordingly?

    Please let me know how can I proceed?

    Saturday, June 28, 2014 6:59 PM
  • You can hide the sections, but the data will still be available using advanced find or the SDK.

    for this purpose Dynamics CRM offers Field Level Security


    if it is not enough for your requirements you should enforce the security using plugins

    My blog: www.crmanswers.net - Rockstar 365 Profile

    Saturday, June 28, 2014 7:29 PM
  • Use field level security to hide the data against the role.

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay

    Monday, June 30, 2014 6:57 AM