locked
Visibility and Editability through Business Rules RRS feed

  • Question

  • I have a single line text field called OtherTopic for a Create Case form. I don't want it visible or editable unless someone selects "Other" from a drop-down of another field called Support Topic. If someone selects "Other" from the drop-down, I want the OtherTopic field to be displayed and required. For the OtherTopic field properties, I have visible by default unchecked.

    I created a business rule with the condition - If Support Topic equals "Other" and the actions - Show field OtherTopic and Set OtherTopic as Business Required.

    After I activate the business rule, save the form, and publish the form. It only works halfway. When I first open the form, I don't see the OtherTopic field (labeled "Other (please enter here)" in the form). But once I select "Other" from the Support Topic drop-down, the OtherTopic field displays, but I can't add any text? Why? Am I missing something? I've even tried adding an additional action to the business rule that says Unlock OtherTopic. But that didn't make a difference. Any suggestions? We're using CRM 2013 On-Premise if that makes any difference.

    Friday, October 17, 2014 2:20 PM

Answers

  • Figured it out from this post: CRM 2011-How to hide/show fields based on lookup value?

    https://social.microsoft.com/Forums/en-US/e9043d6b-304f-46de-b1ba-8bdee5581b7b/crm-2011how-to-hideshow-fields-based-on-lookup-value?forum=crm (Couldn't hyperlink it, because my account still needs to be verified.)

    I made my OtherTopic field visible by default. Then I created a new form control OnLoad, by tweaking the code referenced in the other post: 

    var optValue = Xrm.Page.getAttribute("new_supporttopic").getValue();
    var optText = Xrm.Page.getAttribute("new_supporttopic").getText();

    if (optText == "Other") {
       Xrm.Page.getControl("new_othertopic").setVisible(true);
    }
    else {
       Xrm.Page.getControl("new_othertopic").setVisible(false);
    }

    I added it to the event handlers in the form properties, saved, and published. Works like a gem!


    • Marked as answer by Erica.D Friday, October 17, 2014 4:02 PM
    • Edited by Erica.D Friday, October 17, 2014 4:07 PM
    Friday, October 17, 2014 4:02 PM