MS Dynamics CRM 2013: Disable the ‘+’ icon on Sub-Grid based on Status Reason


Scenario: Disable the “+” icon on the sub-grid. I.e. Disable “+” icon on the Budget entity’s sub-grid (Funds) when the Budget records status reason is “Approval Pending” or “Approved”.

Solution:

1. Download and Import the Ribbon Work Bench solutionUploadWorkbench

2. Add a Custom JavaScript Script with the function “DisableNewButton”

function DisableNewButton() {var status = Xrm.Page.getAttribute(‘statuscode’).getValue(); //if status reason is Approved or Approval Pending if (status == 100000001 || status == 100000002) { returnfalse; } else returntrue; }

3. Open Workbench and select the solution which has the entity on which “+” icon should be disabled for Sub-Grid.

OpenSolution

4. Select the “Fund” entity, select the “Add New {0}” button and “+NEW {0}” button, right click and click on Customise Command.

ButtonCustomize

5. Select Enable Rules and Add New Rule

AddEnableRule

6. Right click the newly created enable rule and click on “Add Rule” AddRule

7. Select the “Custom Javascript Rule”

CustomRule

8. Fill the properties with “FunctionName” and “Library”. Set Default value to “True” and InvertResult to “False”

CustomRuleFunction

9. Select the command for both buttons, right click and click the “Edit Enable Rules” AddEnableRuleToCommand

10. Add the newly created enable rule

AddCustomRule

11. Publish the solution.

:Kishore Dhanekula

Advertisements

About Kishore Dhanekula

MS Dynamics CRM and .NET Architect
This entry was posted in CRM, Java Script, Ms Dynamics CRM 2013 and tagged , , , , , , , . Bookmark the permalink.

8 Responses to MS Dynamics CRM 2013: Disable the ‘+’ icon on Sub-Grid based on Status Reason

  1. hari says:

    very helpful

  2. roxanna says:

    Is this a supported customization for CRM 2013?
    Thanks

  3. stefanooch says:

    I have a custom security role and it looks like the enable script is not running … when I log in as sys admin it seems to execute. Is this privilege related and if so what privs does the role need

  4. amit yadav says:

    Great

  5. Amit Jain says:

    HI Kishor i have followed all the steps exactly how you mentioned but its not working.I am working on CRM 2015 could you suggest me some possible mistake i might be doing?

    • Jaydip Patil says:

      HI Kishor i have followed all the steps exactly how you mentioned but its not working.I am working on CRM 2013 SP 1 Rollup 3 could you suggest me some possible mistake i might be doing?

      • Hi Jaydip,

        Sorry I haven’t checked your comment. I have tested this today as well on CRM 2016. It is working fine.

        Please let me know if this issue still persist. I can help you out.

        Thanks:
        Kishore

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s