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 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

I have the same question (0)
  • Suggested answer
    Pranesh M Juwale Profile Picture
    1,196 on at

    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.

  • Suggested answer
    Community Member Profile Picture
    on at

    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
    ashlega Profile Picture
    34,477 on at

    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.

  • Community Member Profile Picture
    on at

    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.

  • ashlega Profile Picture
    34,477 on at

    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

  • Suggested answer
    velmurugans Profile Picture
    5 on at

    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();

       });

     }

    }

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