Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to hide unwanted Activity types from sub-grid?

(0) ShareShare
ReportReport
Posted on by 195

How to hide unwanted Activity types from sub-grid?  is it possible to hide the unwanted activity types hide from the Sub grid.

i want to block the user from creating the unwanted activities i.e Task, Letter, Campaign Response,Appointment etc from activity sub grid which is placed on other entity form.

7658.screen.jpg

*This post is locked for comments

  • Suggested answer
    velmurugans Profile Picture
    5 on at
    RE: How to hide unwanted Activity types from sub-grid?

    Its possible. I found the way to do it finally after just 3 days of research.

    Open your CRM web in XRM Tool kit (download if not having it) XRM toolkit access your org using url and login. Assuming you have privilege access. Load all web resources and scroll down to find "activitypointer_ribbon_home.js" Add below lines of code into the file, finally Save and publish to make it available for all users. Whoa.. it works like charm !!!

    hideactivitiesview() // call under onload of xrm page; comes in default script of this file

    function hideactivitiesview()

    {

     var viewSelector = $('#crmGrid_SavedNewQuerySelector')[0];

     if(viewSelector)

     {

       $(viewSelector).click(function(){

         var _activity = $('#ViewSelector_activity')[0]; //get this id from DOM using F12

         if(_activity)

           $(_activity).hide();

       });

     }

    }

  • ashlega Profile Picture
    34,477 on at
    RE: How to hide unwanted Activity types from sub-grid?

    For the plugins, you can always create a new field on the activity entities and populate it when creating activity records from the plugins. That approach with sync workflows would have to be converted into "sync plugins" then, but, in the end, you would just verify if that extra attribute is present, and, if yes, you won't raise an exception

  • Community Member Profile Picture
    on at
    RE: How to hide unwanted Activity types from sub-grid?

    Yes that would work & would handle preventing the creation of those activity types from other places.

    But in my case, we wanted to be able to create these activity types from plugins, etc. , but not from the Activity sub grid.

    So it all depends on your requirements.

  • Suggested answer
    ashlega Profile Picture
    34,477 on at
    RE: How to hide unwanted Activity types from sub-grid?

    Hi,

     there is a little "ugly" way of doing the same - created a workflow that will start "on create" of an activity you don't want to be created, check the user name, and stop the workflow as "cancelled".

     Just make sure it's a real-time worfklow.

     The user will see an error message (business process error + whatever you will set in the properties of that "cancel workflow" step)

     It's fully supported, it will stop your users from creating unwanted activities.. but it's less user-friendly.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to hide unwanted Activity types from sub-grid?

    This is probably NOT supported, but it works, at least in CRM 2013 where I implemented it.

    Add the following function to a java script web resource.

    var _activitiesGridName = '';
    function SetupActivityGridOnload(gridName)
    {
        var btnsToHide =
            [
                'AddserviceappointmentButton',
                'AddcampaignresponseButton',
                'AddappointmentButton'
            ];
        _activitiesGridName = gridName;
        setTimeout(function ()
        {   //setting timeout because subgid takes some time to load after the form is loaded
            if (Xrm.Page != null && Xrm.Page != undefined)
            {   //validating to check if the sub grid is present on the form
                var grid = Xrm.Page.getControl(_activitiesGridName);
                if (!grid)
                {   // grid not loaded yet - call function again to recheck after timeout
                    console.log('grid not loaded yet');
                    SetupActivityGridOnload(_activitiesGridName);
                }
                else
                {   // grid loaded now hide unwanted activity buttons
                    var menuItem = null;
                    var parentMenu = null;
                    $.each(btnsToHide, function (i, val)
                    {
                        menuItem = document.getElementById(val);
                        if (menuItem)
                        {
                            if (parentMenu == null)
                            {   // load parent node - if not already loaded
                                parentMenu = menuItem.parentNode;
                            }
                            console.log('removing menu item: ' + val);
                            parentMenu.removeChild(menuItem);
                        }
                        else
                        {
                            console.log('menu not found: ' + val);
                        }
                    });
                }
            }
        }, 2000);
    }
    


    Then call the function from the OnLoad event, adding the grid name as a parameter like so

    ActivityGridInit.png

  • Suggested answer
    Pranesh M Juwale Profile Picture
    1,196 on at
    RE: How to hide unwanted Activity types from sub-grid?

    Hi,

    There is no supported way of doing this.

    A workaround would be to hide the drop down ribbon button and a custom dropdown created with buttons similar to the standard ones.This is little complex and it can cost you manipulation of core ribbon command customisation.

    I would suggest not to go for it.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,311 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,183 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans