We were inspired from an answer on a similar question on the Microsoft social community. We have followed this solution as base and extended it with a custom Javascript function to achieve our purposes.
The question and answers mentioned above are at the following URL:
http://social.microsoft.com/Forums/en-US/a5a0666f-8a07-4b25-92a3-e36ce8861d04/crm-2011-how-to-disable-the-new-activity-ribbon-button-for-a-deactivated-custom-entity
This solution allow the enabling/disabling based on the status of the record (Active / Inactive).
First of all we have developed the Javascript function similar the following:
function addNewActivityEnableRule() {
//Retrieve the parent window Page object
var parentPage =
document.parentWindow.parent.Xrm.Page;
//Gets the desired attribute of the parent window page
var parentPageAttribute = parentPage.getAttribute('parentPage_attributeName');
//Check if attribute exists
if (parentPageAttribute) {
//Get the value of the attribute
//Get the value of the attribute
var parentPageAttributeValue =
parentPageAttribute.getValue();
//'value_for_enabling' : replace with the desired value
(or extend the condition as needed)
(or extend the condition as needed)
//Return true for the conditions where you want enable
the ribbon button and false otherwise
the ribbon button and false otherwise
if (parentPageAttributeValue == 'value_for_enabling') {
return true;
} else {
return false;
}
}
}
Our solution consists of the following steps:
1. Create a solution with the ‘Activity’ entity in it
2. Open the Solution in the Ribbon Workbench
3. Select 'Activity' entity (activitypointer)
4. Select the 'SubGrid' ribbon in the top right drop down
5. Select the 'New {0}' button and right-click -> Customise Command. Don’t select 'Customise Button'!
7. In the 'Solution Elements', expand the 'Commands' and select the 'Mscrm.NewRecordFromGrid' command and Right-Click ->'Edit Enable Rules'
8. Click 'Add New' and then 'Add Step'. Select a 'Custom Javascript Rule'
9. Set the properties:
1. InvertResult: False
2. Default: False
10. Provide the function name and the web resource script library where the function resides
11. Click 'Publish Solution'
Hope it can be useful
Happy CRM coding
Rate this posting:
{[['']]}
No comments:
Post a Comment