Asked by:
crm lookup additionalparam search value with & gives error

Question
-
I have lookup in my order product form. for a custom entity. I need to limit the lookup by passing search values from order product name and customer id for the order.
this lookup works unless there is no & in the order product name. I have generate search string on form onload and I tried to replace & using pdesc = pdesc.replace(/\&/g,'%26'); but this is not working . gives error page I did same for + sign pdesc = pdesc.replace(/\+/g,'%2B'); now lookup works if product name got + sign. how do i avoid & in order product so the lookup works?
my javascript , any help appriciated...
var pdesc = crmForm.all.productid.DataValue[0].name.toString(); pdesc = pdesc.replace(/\+/g,'%2B'); pdesc = pdesc.replace(/\&/g,'%26'); if (cus==''){ crmForm.all.new_servicechargeid.additionalparams = 'search=' +pdesc; } else { cus= cus.replace('{',''); cus=cus.replace('}',''); var filterCondition = "<filter type='and'>" + "<condition attribute='qg_description' operator='eq' value='"+pdesc+"'/>" + "<condition attribute='qg_accountid' operator='eq' value='"+cus+"'/>" + "</filter>"; var fetchXML; //crmForm.all.new_servicechargeid.lookupbrowse = 1; fetchXML = "<fetch mapping='logical'>" + "<entity name='qg_servicecharge'>" + filterCondition + "</entity></fetch>"; crmForm.all.new_servicechargeid.additionalparams = "search=" + fetchXML; }
Tuesday, August 16, 2011 2:02 PM
All replies
-
Hi,
To set Search paramter you also need to edit lookupsingle.aspx page code as mentioned in the following blog post: http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx also make sure that you have not missed any step.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Jehanzeb.Javeed Tuesday, August 16, 2011 4:45 PM
Tuesday, August 16, 2011 4:45 PM -
I didn't touch aspx files, but this is working if there is no "&" in the search value , why this is not work when passing value got & ?Wednesday, August 17, 2011 10:13 AM
-
Hi,
Try replace the following line in your code:
//FROM
var pdesc = crmForm.all.productid.DataValue[0].name.toString();
//TO
var pdesc = encodeURIComponent( crmForm.all.productid.DataValue[0].name );
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Jehanzeb.Javeed Saturday, August 27, 2011 11:14 AM
Wednesday, August 17, 2011 10:29 AM -
Hi, did you find an answer to this question? Running into the same problem here...
Thursday, December 1, 2011 1:19 PM -
Found it myself: replace "&" with "%26" works.
Thursday, December 1, 2011 1:25 PM -
Hi,
encodeURIComponent( value ); function do the same and encode the value as mentioned above.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".Thursday, December 1, 2011 1:29 PM