Here in my case, I've 3 entity ExamReport(fig2),Course and CourseSubject(fig1). Each Course has many CourseSubjects. In ExamReport record, based on Course it should filtered and show the CourseSubject record which is belonging to select Course record .
// Paste this javascript to ExamReport Entity and call it onChange Event of Course attribute(lookup)
function mylookup1()
{
// enter the scheme name lookup attribute of Course in ExamReport
var advert = Xrm.Page.getAttribute("new_course").getValue();
var aname = advert[0].name;
var aid = advert[0].id;
// this guid is obtained from "online GUID generator"(IE)
var viewId = "{2fb903e5-1873-41ac-87cd-ba18e08bc5e4}";
// Enter the scheme name of coursesubject
var entityName = "new_coursesubject";
var viewDisplayName = "Active Subjects for "+aname;
var fetchXml =
// Here we need to paste fetch xml code and modify according to this format
// change" into ', Remove <attribute name="createdon" />
// Remove uiname="Java" uitype="new_course" value="{A89857E26-2231-E111-B8D4-000C295BE9F1}"
// in download fetch xml.
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='new_coursesubject'>"+
"<attribute name='new_coursesubjectid' />"+
"<attribute name='new_subjectname' /> "+
"<order attribute='new_subjectname' descending='false' />"+
"<filter type='and'>"+
"<condition attribute='new_courseid' operator='eq' value='" + aid + "' />"+
"</filter>"+
"</entity>"+
"</fetch>";
//build grid layout
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='new_coursesubjectid' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='new_coursesubjectid' >" +
"<cell name='new_subjectname' " +
"width='300' />" +
"disableSorting='1' />" +
"</row>" +
"</grid>";
//add new view view
Xrm.Page.getControl("new_subject1").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
Xrm.Page.getControl("new_subject2").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
// fitered lookup based on semester and course (javascript)
function filteredlookupforcoursesubjects()
{
var advert = Xrm.Page.getAttribute("new_course").getValue();
var aname = advert[0].name;
var aid = advert[0].id;
var sem = Xrm.Page.getAttribute("new_semester").getValue();
//build fetchxml
var viewId = "{62a56ce8-ed64-4e5b-92c6-6b0b36175dd6}";
var entityName = "new_coursesubject";
var viewDisplayName = "Active Subjects for "+aname;
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='new_coursesubject'>"+
"<attribute name='new_coursesubjectid' />"+
"<attribute name='new_subjectname' /> "+
"<order attribute='new_subjectname' descending='false' />"+
"<filter type='and'>"+
"<condition attribute='new_courseid' operator='eq' value='" + aid + "' />"+
"<condition attribute='new_semester' operator='eq' value='" + sem + "' />"+
"</filter>"+
"</entity>"+
"</fetch>";
//build grid layout
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='new_coursesubjectid' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='new_coursesubjectid' >" +
"<cell name='new_subjectname' " +
"width='300' />" +
"disableSorting='1' />" +
"</row>" +
"</grid>";
//add new view view
Xrm.Page.getControl("new_subject1").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
Xrm.Page.getControl("new_subject2").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
// Paste this javascript to ExamReport Entity and call it onChange Event of Course attribute(lookup)
function mylookup1()
{
// enter the scheme name lookup attribute of Course in ExamReport
var advert = Xrm.Page.getAttribute("new_course").getValue();
var aname = advert[0].name;
var aid = advert[0].id;
// this guid is obtained from "online GUID generator"(IE)
var viewId = "{2fb903e5-1873-41ac-87cd-ba18e08bc5e4}";
// Enter the scheme name of coursesubject
var entityName = "new_coursesubject";
var viewDisplayName = "Active Subjects for "+aname;
var fetchXml =
// Here we need to paste fetch xml code and modify according to this format
// change" into ', Remove <attribute name="createdon" />
// Remove uiname="Java" uitype="new_course" value="{A89857E26-2231-E111-B8D4-000C295BE9F1}"
// in download fetch xml.
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='new_coursesubject'>"+
"<attribute name='new_coursesubjectid' />"+
"<attribute name='new_subjectname' /> "+
"<order attribute='new_subjectname' descending='false' />"+
"<filter type='and'>"+
"<condition attribute='new_courseid' operator='eq' value='" + aid + "' />"+
"</filter>"+
"</entity>"+
"</fetch>";
//build grid layout
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='new_coursesubjectid' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='new_coursesubjectid' >" +
"<cell name='new_subjectname' " +
"width='300' />" +
"disableSorting='1' />" +
"</row>" +
"</grid>";
//add new view view
Xrm.Page.getControl("new_subject1").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
Xrm.Page.getControl("new_subject2").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
// fitered lookup based on semester and course (javascript)
function filteredlookupforcoursesubjects()
{
var advert = Xrm.Page.getAttribute("new_course").getValue();
var aname = advert[0].name;
var aid = advert[0].id;
var sem = Xrm.Page.getAttribute("new_semester").getValue();
//build fetchxml
var viewId = "{62a56ce8-ed64-4e5b-92c6-6b0b36175dd6}";
var entityName = "new_coursesubject";
var viewDisplayName = "Active Subjects for "+aname;
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='new_coursesubject'>"+
"<attribute name='new_coursesubjectid' />"+
"<attribute name='new_subjectname' /> "+
"<order attribute='new_subjectname' descending='false' />"+
"<filter type='and'>"+
"<condition attribute='new_courseid' operator='eq' value='" + aid + "' />"+
"<condition attribute='new_semester' operator='eq' value='" + sem + "' />"+
"</filter>"+
"</entity>"+
"</fetch>";
//build grid layout
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='new_coursesubjectid' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='new_coursesubjectid' >" +
"<cell name='new_subjectname' " +
"width='300' />" +
"disableSorting='1' />" +
"</row>" +
"</grid>";
//add new view view
Xrm.Page.getControl("new_subject1").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
Xrm.Page.getControl("new_subject2").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
No comments:
Post a Comment