Thank you - I was able to achieve desired results. Once I added this JS, another conflict arose when applying show/hide to other fields based on selection. Here is the JS I am using to show/hide four different fields on the same form.
//This shows or hides MSPMClass1
fd.spRendered(function() {
function hideOrShowexam() {
if (fd.field('exam').value == 'MSPM') {
// Show the MSPMClass1
$(fd.field('MSPMClass1').$parent.$el).show();
} else {
// Hide the MSPMClass1
$(fd.field('MSPMClass1').$parent.$el).hide();
}
}
// Calling hideOrShowexam when the user changes exam
fd.field('exam').$on('change',hideOrShowexam);
// Calling hideOrShowexam on form loading
hideOrShowexam();
});
I found that after adding the code and following the "Cascading Lookups" documentation, my other show/hide code no longer worked. I tried various approaches and was able to get them to appear, but now they ALL display.
My sense is that I am missing some way to differentiate between the field filters. I am stuck.
// Cascading Lookups || Trying category=exam_products=team (works)
function filterteam(exam) {
var examId = exam && exam.LookupId || exam || null;
fd.field('team').filter = 'exam/Id eq ' + examId;
fd.field('team').widget.dataSource.read();
}
fd.spRendered(function() {
fd.field('team').ready().then(function() {
//filter team when exam changes
fd.field('exam').$on('change', function(value){
filterteam(value);
fd.field('team').value = null;
});
//filter team when form opens
fd.field('exam').ready().then(function(field) {
filterteam(field.value);
});
});
});
//This shows or hides CNSRClass1 (shows multiple classes)
fd.spRendered(function() {
function hideOrShowexam() {
var examId = exam && exam.LookupId || exam || null;
if (fd.field('exam').filter = 'exam/Id eq ' + examId == 'CNSR') {
// Show the CNSRClass1
$(fd.field('CNSRClass1').$parent.$el).show();
} else {
// Hide the CNSRClass1
$(fd.field('CNSRClass1').$parent.$el).hide();
}
}
// Calling hideOrShowexam when the user changes exam
fd.field('exam').$on('change',hideOrShowexam);
// Calling hideOrShowexams on form loading
hideOrShowexam();
});
//This shows or hides MSPMClass1 (shows multiple classes)
fd.spRendered(function() {
function hideOrShowexam() {
var examId = exam && exam.LookupId || exam || null;
if (fd.field('exam').filter = 'exam/Id eq ' + examId == 'MSPM') {
// Show the MSPMClass1
$(fd.field('MSPMClass1').$parent.$el).show();
} else {
// Hide the MSPMClass1
$(fd.field('MSPMClass1').$parent.$el).hide();
}
}
// Calling hideOrShowexam when the user changes exam
fd.field('exam').$on('change',hideOrShowexam);
// Calling hideOrShowexam on form loading
hideOrShowexam();
});