locked
filter lookup view by fetchxml RRS feed

  • Question

  • hi all,

    i get this error when trying to open lookup view

    http://192.168.1.46:5555/IT/_common/error/errorhandler.aspx?ErrorCode=&RequestUri=%2fITC%2f_controls%2flookup%2flookupsingle.aspx%3fclass%3dnull%26objecttypes%3d10008%26browse%3d1%26fetchXml%3d%253Cfetch%2520mapping%253D%27logical%27%2520%2520version%253D%271.0%27%2520output-format%253D%27xml-platform%27%253E%253Centity%2520name%253D%27new_documents%27%253E%253Cattribute%2520name%253D%27new_name%27%2520%252F%253E%253Cfilter%253E%253Ccondition%2520attribute%253D%27new_name%27%2520operator%253D%27like%27%2520value%253D%27Goods%2525%27%2520%252F%253E%253C%252Ffilter%253E%253C%252Fentity%253E%253C%252Ffetch%253E%26ShowNewButton%3d1%26ShowPropButton%3d1%26DefaultType%3d0&BackUri=

    var field = crmForm.all.new_stepid;
    field.lookupbrowse =1;
    var fetch="<fetch mapping='logical' version='1.0' output-format='xml-platform'><entity name='new_documents'><attribute name='new_name' /><filter><condition attribute='new_name' operator='like' value='Goods%' /></filter></entity></fetch>";
    
    field.additionalparams = "fetchXml=" +encodeURIComponent(fetch);
    how can i pass fetchxml as parameter    


    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I love u !!")
    Tuesday, April 27, 2010 9:41 AM

Answers

  • Hi Dany,

    In case of CRM 4 to get the filtered lookup thing working, we need to add the "search" parameter as Vinoth suggested and we also need to make some changes to 

    lookupsingle.aspx page.

    http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx

     

    Regards,

    Nishant Rana

     


    http://nishantrana.wordpress.com
    • Marked as answer by Dany85 Tuesday, April 27, 2010 11:26 AM
    Tuesday, April 27, 2010 11:09 AM
  • I hope you are trying to retrieve the fetchxml records equivalent to the below SQL query

    SELECT new_name from new_documents WHERE new_name like 'Goods%'

    Then the problem is in the fetchxml. It should be like below.

    var field = crmForm.all.new_stepid;
    field.lookupbrowse = 1;
    field.AddParam("search","<fetch mapping='logical'><entity name='new_documents'><attribute name='new_name'/><filter type='and'><condition attribute='new_name' operator='like' value='Goods&#37;'/></filter></entity></fetch>");

    Rgards
    Vinoth

     

     

    • Proposed as answer by VinothBalasubramanian Tuesday, April 27, 2010 11:10 AM
    • Marked as answer by Dany85 Tuesday, April 27, 2010 11:26 AM
    Tuesday, April 27, 2010 11:10 AM
  • As nishanth stated had you made modification in lookupsingle.aspx page as per the below link?

    http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx

    Did you use the below javascript code? (Note that the % is replaced with &#37;)

    var field = crmForm.all.new_stepid;
    field.lookupbrowse = 1;
    field.AddParam("search","<fetch mapping='logical'><entity name='new_documents'><attribute name='new_name'/><filter type='and'><condition attribute='new_name' operator='like' value='Goods&#37;'/></filter></entity></fetch>");

    Please try this and let us know your inferences.

     

    • Marked as answer by Dany85 Tuesday, April 27, 2010 11:26 AM
    Tuesday, April 27, 2010 11:25 AM

All replies

  • try this. ensure your fetchxml is correct

    var field = crmForm.all.new_stepid;
    field.lookupbrowse = 1;
    field.AddParam("search","<fetch mapping='logical' version='1.0' output-format='xml-platform'><entity name='new_documents'><attribute name='new_name' /><filter><condition attribute='new_name' operator='like' value='Goods%' /></filter></entity></fetch>");

    Tuesday, April 27, 2010 9:48 AM
  • hi Vinoth,

    i need to get many records which achieved by fetch xml

    so fetch return many records not only one so i can not use search parameter


    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I love u !!")
    Tuesday, April 27, 2010 10:52 AM
  • The above format will return all new_documents (not one) records which satisfied the fetchxml condition.

    Have you tried it? It returns only one?

    Tuesday, April 27, 2010 10:56 AM
  • it returns no data it just put the fetch string in lookup search box
    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I love u !!")
    Tuesday, April 27, 2010 11:05 AM
  • Hi Dany,

    In case of CRM 4 to get the filtered lookup thing working, we need to add the "search" parameter as Vinoth suggested and we also need to make some changes to 

    lookupsingle.aspx page.

    http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx

     

    Regards,

    Nishant Rana

     


    http://nishantrana.wordpress.com
    • Marked as answer by Dany85 Tuesday, April 27, 2010 11:26 AM
    Tuesday, April 27, 2010 11:09 AM
  • I hope you are trying to retrieve the fetchxml records equivalent to the below SQL query

    SELECT new_name from new_documents WHERE new_name like 'Goods%'

    Then the problem is in the fetchxml. It should be like below.

    var field = crmForm.all.new_stepid;
    field.lookupbrowse = 1;
    field.AddParam("search","<fetch mapping='logical'><entity name='new_documents'><attribute name='new_name'/><filter type='and'><condition attribute='new_name' operator='like' value='Goods&#37;'/></filter></entity></fetch>");

    Rgards
    Vinoth

     

     

    • Proposed as answer by VinothBalasubramanian Tuesday, April 27, 2010 11:10 AM
    • Marked as answer by Dany85 Tuesday, April 27, 2010 11:26 AM
    Tuesday, April 27, 2010 11:10 AM
  • Dear Vinoth,

    i execute the query is sql query and i got the match records, but when i put the fetxhxml on my form i get all records which match and do not match


    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I love u !!")
    Tuesday, April 27, 2010 11:19 AM
  • it works , it is my mistake i  add some code to lookupsingle.aspx file.

    and it works now thanks you all


    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I love u !!")
    Tuesday, April 27, 2010 11:25 AM
  • As nishanth stated had you made modification in lookupsingle.aspx page as per the below link?

    http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx

    Did you use the below javascript code? (Note that the % is replaced with &#37;)

    var field = crmForm.all.new_stepid;
    field.lookupbrowse = 1;
    field.AddParam("search","<fetch mapping='logical'><entity name='new_documents'><attribute name='new_name'/><filter type='and'><condition attribute='new_name' operator='like' value='Goods&#37;'/></filter></entity></fetch>");

    Please try this and let us know your inferences.

     

    • Marked as answer by Dany85 Tuesday, April 27, 2010 11:26 AM
    Tuesday, April 27, 2010 11:25 AM