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)

How to make sub grid read only?

(0) ShareShare
ReportReport
Posted on by 320

Hi

i have contact sub grid on Account entity . i want when account status is inactive then sub grid should be read only.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Arun,

    This happens by default i.e. when you deactivate the account record, the add new button gets removed from the subgrid and you can no longer add the contacts from their.

    Are you looking for something else?

  • Ak Negi Profile Picture
    320 on at

    yeah.. new button is removed when record is inactive but i want user should not able to read record from sub grid.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    then you should hide the subgrid with a Javascript function running onLoad. It will check the status and then show/hide your subgrid if it is active/inactive

    Here are some sample functions:

    www.powerobjects.com/.../friday-flash-tip-hide-show-sub-grids-crm-2016-pick-selected-rows-using-javascript

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    here are another post: community.dynamics.com/.../192667

  • Ak Negi Profile Picture
    320 on at

    Thanks Domont

    but i want to show grid as read only.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Ak,

    proceed as follows:

    1) Add statuscode attribute to your form

    2) Move your subgrid to a new section, we name "MYSECTION"

    2) Add a javascript library with the following code to you form

    function FormOnLoad()
    {
        var statecode = Xrm.Page.getAttribute("statecode").getValue();
        if (statecode == 1) // not active
        {
            Xrm.Page.ui.tabs.get('TABWHICHCONTAINSMYSECTION').sections.get('MYSECTION').setVisible(false);
        }
    }

    2) On load events, call FormOnLoad function

    3) You are done!

    Please let me know if you solve.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Suggested answer
    Syed Ibrahim Profile Picture
    6,257 on at

    Hi Arun,

    Pls follow the below forum thread with the verified suggestion and modify your subgrid accordingly.

    community.dynamics.com/.../197142

    Hope this helps. If suggestion resolved your query Mark it as verified to close the thread

  • Suggested answer
    chauhanhardik Profile Picture
    687 on at

    Hi Arun,

    Please insert below code on account form's "onLoad" event.

    here, subGridName=Contacts, which the name of your desired subgrid.

    function subgrid(subGridName)

    {

    debugger;

    if(Xrm.Page.getAttribute("statecode").getValue() == 1)

    {

    Xrm.Page.getControl(subGridName).setVisible(false);

    }

    }

    just copy and paste above code and pass "Contacts" as parameter

    Thanks,

    Hardik Chauhan

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