locked
MS CRM 2011 Filter description field based on lookup value using javascript. RRS feed

  • Question

  • Hi All,

    I have a lookup field called siscode and textbox field of sisdescription.
    I filtered the sisdescription on change of siscode using javascript, its working fine.
    now i need to make the description field blank when remove the sis code.

    (means by mistake i select the siscode and sisdescription has populated, at the same time when i remove the siscode,  so sisdescription value should also be remove automatically.)

    When i remove siscode value so the sisdescription should also be blank.
    i added the javascript in both event.

    Thanks in advance

    Suresh Sorde

    Thursday, October 31, 2013 10:03 AM

All replies

  • Hello,

    Try below script on change of siscode lookup

    if(Xrm.Page.getAttribute("youfieldlookupfield")!=null && Xrm.Page.getAttribute("youfieldlookupfield").getValue()==null)

    {

    Xrm.Page.getAttribute("sisdescriptionfield").setValue(" ");

    }


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thursday, October 31, 2013 10:08 AM
    Moderator
  • Thank you for your replay.

    I tried your code but its not working.

    this is my code:

    var sLookupValue = new Array();
    sLookupValue = Xrm.Page.getAttribute("sislookupfield").getValue();
    if(sLookupValue [0] != null)
    {
        var sisid= sLookupValue [0].id;
    }
    var siscodedesc = function(sisid);
    Xrm.Page.getAttribute("sicdescription").setValue((siscodedesc));
    }

    Thursday, October 31, 2013 10:37 AM
  • Try this

    var sLookupValue = new Array();
    sLookupValue = Xrm.Page.getAttribute("sislookupfield").getValue();
    if(sLookupValue [0] != null)
    {
        var sisid= sLookupValue [0].id;
    var siscodedesc = function(sisid);
    Xrm.Page.getAttribute("sicdescription").setValue((siscodedesc));
    }

    else

    {Xrm.Page.getAttribute("sisdescriptionfield").setValue(" ");}


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, November 1, 2013 7:17 AM
    Moderator