locked
Disable a button based on a condition in CRM 4.0 RRS feed

  • Question

  • I want to disabe a button in CRM 4.0 based on a condition.how do i do this?

    There is an opportunity which can add recurring opportunities by adding the top recurring opportuntiy button.

    this opportunity has 1 recurring opportunity.it can be seen by clicking the recurring opportunities button on the left.

    when i open the recurring opportunity then again it can add its own recurring opportunities.

    the issue is i want to disable the button now.i want the button to create recurring opportunities only from originating opportunity and not from any recurring opportunity.how to do???originating opportunities have crmp_originatingopportunityid = null.this condition can be used.but how?i need the javascript code.please help.please see below screenshots.test for update is the Original Opportunity. Test for Update along with date is the RO.

    Tuesday, February 25, 2014 3:58 PM

Answers

  • In Dynamics CRM 4.0 this can not be done in a supported way. You will have to revert to unsupported Javascript/DOM tweaks (looking up the button's DOM element and disabling it). 'Unsupported' means your code will not survive a migration to CRM 2011 or CRM 2013. So, you can do this and your customization will be relatively harmless, but you are doing it at your own risk.

    In CRM 2011/2013 your requirement can be fulfilled in a supported way.


    If this post is an answer or helpful, please do not forget to vote!

    • Marked as answer by Bachchan11 Wednesday, March 12, 2014 10:04 AM
    Tuesday, February 25, 2014 8:22 PM
  • Hi Amlan,

    Not sure why it's not working, it should be. You might want to debug your code and check that all conditions satisfy as they are supposed to be.

    • Marked as answer by Bachchan11 Wednesday, March 12, 2014 10:04 AM
    Wednesday, February 26, 2014 12:00 PM

All replies

  • In Dynamics CRM 4.0 this can not be done in a supported way. You will have to revert to unsupported Javascript/DOM tweaks (looking up the button's DOM element and disabling it). 'Unsupported' means your code will not survive a migration to CRM 2011 or CRM 2013. So, you can do this and your customization will be relatively harmless, but you are doing it at your own risk.

    In CRM 2011/2013 your requirement can be fulfilled in a supported way.


    If this post is an answer or helpful, please do not forget to vote!

    • Marked as answer by Bachchan11 Wednesday, March 12, 2014 10:04 AM
    Tuesday, February 25, 2014 8:22 PM
  • Thanks Henk for the reply.I am up for that.The migration would not happen for a long time.so no issue with that.

    could you please let me know the javascript code.i dont know what to write.

    thanks in advance

    Wednesday, February 26, 2014 7:13 AM
  • Hi Amlan,

    Like already pointed out, this is unsupported and might possible break even if you install any new rollups (in case you have any pending rollups for CRM 4.0). To do it, press F12, and use IE developer tools to get the Id/Name of the button that you want to hide. After this it's your logic when you want to hide/show it and once you have the Id/Name of the button rendered you can use simple javascript to hide/show it.



    Wednesday, February 26, 2014 9:34 AM
  • Thanks Dynamotion for the reply.I followed the same procedure what you mentioned above.My code is below.It is still not working.What I am doing wrong???

    var RO=document.getElementById('ISV_New_17_Recurringopportunity');

    if(crmForm.all.crmp_originatingopportunityid.DataValue==null)

    {RO.style.display='inline';}

    if(crmForm.all.crmp_originatingopportunityid.DataValue!=null)

    {RO.style.display='none';}

    It is still not working.Why??

    Wednesday, February 26, 2014 11:16 AM
  • Hi Amlan,

    Did you try debugging the code and check if the RO resolves and references to the actual button you're trying to hide/show?

    Wednesday, February 26, 2014 11:26 AM
  • I checked the developer tools and found that the id of the button is 'ISV_New_17_Recurringopportunity'.

    the reference is correct.

    Wednesday, February 26, 2014 11:51 AM
  • Hi Amlan,

    Not sure why it's not working, it should be. You might want to debug your code and check that all conditions satisfy as they are supposed to be.

    • Marked as answer by Bachchan11 Wednesday, March 12, 2014 10:04 AM
    Wednesday, February 26, 2014 12:00 PM