locked
Hide field on Action of a Lookup Field RRS feed

  • Question

  • Hi,

    On my lead entity I have a lookup field called new_TradingDistance with 6 or so options, but for two of the options "Near" (guid - 4284BB94-3C08-DF11-97CA-000C29474E1C) and "Very Near"- I want to reveal another field called new_days, otherwise it stays hidden on the form. 

    I've got this working for picklists and I've seen lots of solutions but not for lookups.  Any code would be greatly appreciated

    Monday, January 25, 2010 1:06 PM

Answers

  • Hi,

    The code below demonstrates how you would hide or show the new_days field based on the value selected in the lookup new_tradingdistance.


    //Add code to hide and show the new_days field.

    var lookupItem = new Array;

    lookupItem = crmForm.all.new_TradingDistance.DataValue;

    // If there is data in the field, show it in a series of alerts.
    if (lookupItem[0] != null)
    {
       // The text value of the lookup.
       if(lookupItem[0].name == "Very Near" || lookupItem[0].name == "Near"  )
       {
       //Show new_days
       }else
       {
             //Hide new_days
       }
    }


    Hassan.


    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    • Proposed as answer by Hassan Hussain Monday, January 25, 2010 1:28 PM
    • Marked as answer by Jimbo64 Monday, January 25, 2010 2:01 PM
    Monday, January 25, 2010 1:28 PM

All replies

  • Hi,

    The code below demonstrates how you would hide or show the new_days field based on the value selected in the lookup new_tradingdistance.


    //Add code to hide and show the new_days field.

    var lookupItem = new Array;

    lookupItem = crmForm.all.new_TradingDistance.DataValue;

    // If there is data in the field, show it in a series of alerts.
    if (lookupItem[0] != null)
    {
       // The text value of the lookup.
       if(lookupItem[0].name == "Very Near" || lookupItem[0].name == "Near"  )
       {
       //Show new_days
       }else
       {
             //Hide new_days
       }
    }


    Hassan.


    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    • Proposed as answer by Hassan Hussain Monday, January 25, 2010 1:28 PM
    • Marked as answer by Jimbo64 Monday, January 25, 2010 2:01 PM
    Monday, January 25, 2010 1:28 PM
  • Thanks Hassan

    I was able to do finish it with this.

    Jim
    Monday, January 25, 2010 2:01 PM
  • Hi all

    I've got it working and added in the show / hide, but my show highlighted in bold code doesn't seem to work. Any ideas on where I've gone wrong?



    //Add code to hide and show the new_days field.

    var lookupItem = new Array;
    var hideValues = (crmForm.all.new_howfartotradeid!= null) &&

    lookupItem = crmForm.all.new_howfartotradeid.DataValue;

    // If there is data in the field, show it in a series of alerts.
    if (lookupItem[0] != null)
    {
       // The text value of the lookup.
       if(lookupItem[0].name == "Just Started Trading" || lookupItem[0].name == "Near to Trade - in a month")
       {
       //Show new_days


    crmForm.all.new_businessplan_d.style.display = displayStyle;
    crmForm.all.new_businessplan_c.style.display = displayStyle;

       }else
       {
             //Hide new_days

    crmForm.all.new_businessplan_c.style.visibility = "hidden";
    crmForm.all.new_businessplan_d.style.visibility = "hidden";

       }
    }

    Monday, January 25, 2010 3:09 PM