locked
How to write a Javascript for hiding lookup value id is null in MSCRM 2011 RRS feed

  • Question

  • Hi,

    Can anyone help me how to write a JavaScript for hiding a lookup value if its value is null.

    As per my requirement I have 2 lookup values in one form if it's values are null while opening the record that lookup has to be hide.

    For example :In contact Entity I have 2 lookups

    one is for USER Lookup and another one is for Account Lookup while opening the record of contact entity and navigating to USER record if the value is null for USER  I need to hide the lookup.

    Thanks,


    Thanks, Toushu


    • Edited by Rahul-22 Saturday, May 25, 2013 2:14 AM
    Saturday, May 25, 2013 1:32 AM

Answers

  • I am not too sure why you want to hide null/blank lookup ? but as long as it meets your requirements

    Try this code: 

    if (Xrm.Page.getAttribute("new_lookupfieldname").getValue() == null)
      {
          Xrm.Page.ui.controls.get("new_lookupfieldname").setVisible(false);
      }


    hope it helps,


    cheers, S.Khan MCTS

    • Proposed as answer by Guido PreiteMVP Saturday, May 25, 2013 9:45 AM
    • Marked as answer by Rahul-22 Tuesday, May 28, 2013 9:40 AM
    Saturday, May 25, 2013 6:28 AM

All replies

  • Hi,

    Have a look at this library. That could help you through hiding a field based on another field.



    My Weblog | My Website

    Saturday, May 25, 2013 3:13 AM
    Moderator
  • I am not too sure why you want to hide null/blank lookup ? but as long as it meets your requirements

    Try this code: 

    if (Xrm.Page.getAttribute("new_lookupfieldname").getValue() == null)
      {
          Xrm.Page.ui.controls.get("new_lookupfieldname").setVisible(false);
      }


    hope it helps,


    cheers, S.Khan MCTS

    • Proposed as answer by Guido PreiteMVP Saturday, May 25, 2013 9:45 AM
    • Marked as answer by Rahul-22 Tuesday, May 28, 2013 9:40 AM
    Saturday, May 25, 2013 6:28 AM