Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

Filtering Contracts by Customer for a Case entity in CRM 2011

$
0
0

I am migrating my Dynamics installation from CRM 4 to CRM 2011. In my original installation the Customer/Account dropdown in a Case entity has an onchange event which filters Contracts for the selected Customer. The following is the code in the onchange event:

if(crmForm.FormType == 1 || crmForm.FormType == 2) {
	if (!IsNull(crmForm.all.customerid.DataValue)){
		crmForm.all.cscdb_casecontactid.additionalparams = 'search=' + encodeURIComponent(crmForm.all.customerid.DataValue[0].name);
		var acct = crmForm.all.customerid.DataValue[0].name;
		if (acct.indexOf(' -') > -1){
			acct = acct.substring(0,acct.indexOf(' -'));
		};
		acct = acct.substring(0,acct.length-1);
		acct = acct.replace("&","&");
		var fetchStr = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="contract"><attribute name="title"/><attribute name="contractid"/><attribute name="customerid"/><order attribute="title" descending="false"/><filter type="and"><condition attribute="statecode" operator="in"><value>2</value><value>1</value></condition><condition attribute="customeridname" operator="like" value="' + acct + '&#37;"/></filter></entity></fetch>';
		crmForm.all.contractid.lookupbrowse = 1;
		crmForm.all.contractid.additionalparams = 'search=' + encodeURIComponent(fetchStr);
	}
}

What I need to do is exactly the same thing but in my CRM 2011 installation. I have successfully ran some JavaScript on the onchange event and tested this by displaying an alert. Unfortunately copying the same code across does not seem to have the desired result and the entire list of Contracts is displayed in the dropdown. I'd be very grateful if anybody could help me out here by modifying the above code for use in CRM 2011?

Many thanks,

Daniel



Viewing all articles
Browse latest Browse all 10280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>