Announcements
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.
*This post is locked for comments
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();
});
}
}
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
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.
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.
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
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.
André Arnaud de Cal...
293,311
Super User 2025 Season 1
Martin Dráb
232,183
Most Valuable Professional
nmaenpaa
101,158
Moderator