locked
Filter lookup RRS feed

  • Question

  • I am  trying to filter lookup. I have wirte following code. it did not given any error. but default view is display in lookup

    thanks in advance. The new filter not able to attached .

    please suggest

    code:

    function

    setInsuredmemberLookup()

    {

    if (Xrm.Page.data.entity.attributes.get("new_employeeid").getValue() != null)

    {

    var employee = Xrm.Page.getAttribute("new_employeeid").getValue();

    if (employee != null) {

    var employeeid = employee[0].id;

    var employeename = employee[0].name;

    var viewId = "{6222e733-c463-41f7-9ed9-12188396f36c}";

    var entityName = "new_insuredmember";

    var viewDisplayName = "Active employee for " + employeename + "";

    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical'>"

    +

    "<entity name='new_insuredmember'>"

    +

    "<attribute name='new_insuredmemberid' />"

    +

    "<attribute name='new_insuredmembername' />"

    +

    "<attribute name='createdon' />"

    +

    "<order attribute='new_insuredmembername' descending='false' />"

    +

    "</entity>"

    +

    "</fetch>";

    var layoutXml = "<grid name='resultset' " +

    "object='1' " +

    "jump='new_insuredmembername' " +

    "select='1' " +

    "icon='1' " +

    "preview='1'>" +

    "<row name='result' " +

    "id='new_insuredmemberid'>" +

    "<cell name='new_insuredmemberid' " +

    "width='400' />" +

    "</row>" +

    "</grid>";

    Xrm.Page.getControl(

    "new_insuredmemberid").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);

    }

    }

    }

    Saturday, April 21, 2012 5:08 AM

Answers

  • "on change of employeeid lookup. b'z we want to filter according to employee."- It's correct.

    Are you able to see "Active employee for xyz" View when you are trying to select insuredmembers list on lookup view without record list ?

    try to replace your  var layoutXml to as below :-

     var layoutXml = "<grid name='resultset' " +
                "object='1' " +
                "jump='new_insuredmembername' " +
                "select='1' " +
                "icon='1' " +
                "preview='1'>" +
                "<row name='result' " +
                "id='new_insuredmemberid'>" +
                "<cell name='new_insuredmembername' " +
                "width='400' />" +
                "</row>" +
                "</grid>";

    • Edited by _Vikram Saturday, April 21, 2012 6:14 AM
    • Proposed as answer by Linn Zaw Win Saturday, April 21, 2012 7:23 AM
    • Marked as answer by misal anita Saturday, April 21, 2012 9:50 AM
    Saturday, April 21, 2012 5:59 AM
  • thx

    it is working

    • Marked as answer by misal anita Saturday, April 21, 2012 9:49 AM
    Saturday, April 21, 2012 6:59 AM

All replies

  • Hi 

    Where you are calling this function. ?

    Saturday, April 21, 2012 5:17 AM
  • on change of employeeid lookup. b'z we want to filter according to employee.

    but in above fetchxml i write simple query but it is not working.

    why i don't know

    Saturday, April 21, 2012 5:20 AM
  • Try to turn off the view selector and set the default view as a lookup view.

    Saturday, April 21, 2012 5:25 AM
  • no it is not working
    Saturday, April 21, 2012 5:35 AM
  • "on change of employeeid lookup. b'z we want to filter according to employee."- It's correct.

    Are you able to see "Active employee for xyz" View when you are trying to select insuredmembers list on lookup view without record list ?

    try to replace your  var layoutXml to as below :-

     var layoutXml = "<grid name='resultset' " +
                "object='1' " +
                "jump='new_insuredmembername' " +
                "select='1' " +
                "icon='1' " +
                "preview='1'>" +
                "<row name='result' " +
                "id='new_insuredmemberid'>" +
                "<cell name='new_insuredmembername' " +
                "width='400' />" +
                "</row>" +
                "</grid>";

    • Edited by _Vikram Saturday, April 21, 2012 6:14 AM
    • Proposed as answer by Linn Zaw Win Saturday, April 21, 2012 7:23 AM
    • Marked as answer by misal anita Saturday, April 21, 2012 9:50 AM
    Saturday, April 21, 2012 5:59 AM
  • thx

    it is working

    • Marked as answer by misal anita Saturday, April 21, 2012 9:49 AM
    Saturday, April 21, 2012 6:59 AM