In below example, I have implemented custom filter on Student Course Lookup. This filter is forcing the student courses to show for the given Student Id. Student Id is mapped as single line of text field so default filter functionality can not be implemented for Student Course Lookup.
Student Course Lookup Before Filter
Student Course Lookup After Filter
Xrm Code
var studentId = Xrm.Page.getAttribute("cms_studentid").getValue();
var fetchXml = "<filter type='and'>";
fetchXml += "<condition attribute='cms_student' operator='eq' value='" + studentId + "' />";
fetchXml += "</filter>";
Xrm.Page.getControl("cms_studentcourse").addPreSearch(function () {
Xrm.Page.getControl("cms_studentcourse").addCustomFilter(fetchXml);
});
#AW Dynamics CRM Consultant