Dear Ravi Thanks for ur prompt reply
if we write all the code in the addPreSearch method everything works fine for the hardcoded value but when i pass this filter value from run time query result it did't work, even i am unable to debug the code written in addPreSearch method
Xrm.Page.getControl("wc_distirct").addPreSearch(function () {
var userDist = getUserDistricts(Xrm.Page.context.getUserId());
if(userDist.length > 0)
{
var distcount = 0;
var filterStr = "<filter type='and'><filter type='or'>";
for (distcount = 0; distcount < userDist.length; distcount++)
{
filterStr += "<condition attribute='pcl_name' operator='eq' value='"+ userDist[0].attributes["pcl_name"].value +"'/>";
}
filterStr += "</filter></filter>";
Xrm.Page.getControl("wc_distirct").addCustomFilter(filterStr);
}
});
function getUserDistricts(UserId)
{
var fetchDis = " <fetch distinct='true' mapping='logical' output-format='xml-platform' version='1.0'> " +
" <entity name='pcl_district'> " +
" <attribute name='pcl_name'/> <attribute name='pcl_districtid'/> " +
" <order descending='false' attribute='pcl_name'/> " +
" <link-entity name='pcl_pcl_district_systemuser' intersect='true' visible='false' to='pcl_districtid' from='pcl_districtid'> " +
" <link-entity name='systemuser' to='systemuserid' from='systemuserid' alias='ad'> " +
" <filter type='and'> " +
" <condition attribute='systemuserid' value='" + UserId + "' operator='eq'/> " +
" </filter> " +
" </link-entity> " +
" </link-entity> " +
" </entity> " +
" </fetch>";
var userdDist = XrmServiceToolkit.Soap.Fetch(fetchDis);
return userdDist;
}
If i am wrong anywhere than pls guid