CRM 2011: Update selected records in Account grid RRS feed

  • Question

  • We have a button on the Account grid ribbon which should update a field on all selected accounts.

    Can anyone tell me how to convert this CRM 4 function to work in CRM 2011 please?

    function ApplyTierToSelectedRecords(nTier) {
        var a = document.all['crmGrid'].InnerGrid.SelectedRecords;
        var bError = false;
        var totalAccounts = 0;
        var childAccounts = 0;

        for (var i = 0; i < a.length; i++) {
            if (IsTopParent(a[i][0])) {
            else {
                if (SetTier(a[i][0], nTier) == false)
                    bError = true;

        if (childAccounts > 0)
            alert('WARNING! ' + childAccounts + '/' + totalAccounts + ' of the records you selected are not top-level parent records.');
        else {
            if (!bError)
                alert('Tier-selection was successfully applied.');
                alert('WARNING! Errors were encountered whilst applying tier-select.');

    Monday, July 8, 2013 12:50 PM

All replies

  • There is definitely more to this than what your included function is showing, however, in general you will need to convert the function so that it can be called from a custom ribbon action.  You can use a tool like the Ribbon Workbench to edit the ribbon for the account grid.  You will need to create a custom action that calls a JavaScript function.  You can pass various CRM parameters to the custom function using <CrmParameter> elements.  In particular you will probably be interested in the SelectedControlSelectedItemReferences or SelectedControlSelectedItemIds.  This will give you an array of either EntityReference objects or GUIDs, respectively, that you can iterate over in order to update the accounts.

    Without seeing the contents of the IsTopParent and SetTier functions it is hard to say what else you may need to change.  My guess is that those functions are also performing CRM 4 specific actions that will need to be updated.  You can see more about performing ribbon customizations here and also more about using the web services from client applications here.


    Monday, July 8, 2013 2:27 PM