locked
Filter Lookup in Dynamic CRM RRS feed

  • Question

  • Dear all,

    I've create a custome view and i want to filter that load all record A have the id cotain is a "LISTID"

    This is my fetxml

     var fetchXml = "<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>" +
                    "<entity name='new_A'>" +
                        "<attribute name='new_name'/>" +
                        "<order descending='false' attribute='new_name'/>" +
                        "<filter type='and'>" +
                            "<condition attribute='new_name' operator='in'>" +
                                LISTID +
                            "</condition>" +
                        "</filter>" +
                    "</entity>" +
                "</fetch>";

    Is run ok is LISTID have some value

    But when LISTID not contain any value, so all record show in the lookup.

    I want if LISTID does not have any value, then the lookup does not display any record

    Any idea for it

    Wednesday, November 21, 2012 11:57 AM

Answers

  • I got the annswer like this:

    If LISTID == null my condition is "<value>00000000-0000-0000-0000-000000000000</value>"

    else "<value>" +LISTID  + "</value>";

    Hope this help!

    • Marked as answer by AnyMi Thursday, November 22, 2012 3:18 AM
    Thursday, November 22, 2012 3:17 AM

All replies

  • Hi,

    Try to Initialize LISTID with some default value.

    Wednesday, November 21, 2012 12:17 PM
  • You could also write two fetchXMLs below is just a pseudo code.

    if(LISTID == NULL)

    {

    var fetchxml = (Set your fetchXML)

    }

    else

    {

    var fetchXml = "<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>" +
                    "<entity name='new_A'>" +
                        "<attribute name='new_name'/>" +
                        "<order descending='false' attribute='new_name'/>" +
                        "<filter type='and'>" +
                            "<condition attribute='new_name' operator='in'>" +
                                LISTID +
                            "</condition>" +
                        "</filter>" +
                    "</entity>" +
                "</fetch>";

    }


    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!

    Wednesday, November 21, 2012 1:50 PM
  • If this is possible you should disable this field (and enable when listId get a value).
    This is better for user than just to show him an empty list.

    Wednesday, November 21, 2012 9:26 PM
  • I got the annswer like this:

    If LISTID == null my condition is "<value>00000000-0000-0000-0000-000000000000</value>"

    else "<value>" +LISTID  + "</value>";

    Hope this help!

    • Marked as answer by AnyMi Thursday, November 22, 2012 3:18 AM
    Thursday, November 22, 2012 3:17 AM