I have a that the cascading lookups stopped working. I am not sure if this is persistent in other areas but I know I had this working two weeks ago. Is this a known issue? I set the filter using the javascript. It filter is pulling list entries just not those I am expecting.
Quick update. If I select one of the entries and then clear it does filter properly. If I change the filter the resulting lookup does not refilter until I select and then clear it. I am using fd.field('MyFieldName').refresh();
Dear @cwalter2,
Could you share your code with us? We'll have to test it to see if everything is okay. Just created a form with code from this article, all seems to work - Configure cascading lookup fields on a SharePoint form with JavaScript — Forms 1.0 documentation
As a solution, you can also try using new Depends on property of the lookup field and filter by lookup this way - Filter Lookup by another field: Lookup, Person, Choice — Forms 1.0 documentation Just make sure you have the latest App package version.
Here is the code I had per the documentation that is no longer working:
Here is within the spFormRendered section:
fd.field('Add_x0020_Bidder').ready().then(orderBidders);
fd.field('Add_x0020_Bidder_x0020_Contact').ready().then(function() {
fd.field('Add_x0020_Bidder').$on('change', function(value){
cascFilterBidder(value);
fd.field('Add_x0020_Bidder_x0020_Contact').value = null;
});
fd.field('Add_x0020_Bidder').ready().then(function(field) {
cascFilterBidder(field.value);
});
});
Here are my functions referenced:
function cascFilterBidder (addBidder) {
var addBidderId = addBidder && addBidder.LookupId || addBidder || null;
fd.field('Add_x0020_Bidder_x0020_Contact').filter = 'CLCompany/Id eq ' + addBidderId + " and CLActive eq 'Active'";
fd.field('Add_x0020_Bidder_x0020_Contact').orderBy = {field: 'CLDispName', asc: true};
fd.field('Add_x0020_Bidder_x0020_Contact').refresh();
}
function orderBidders () {
fd.field('Add_x0020_Bidder').orderBy = {field: 'Title', asc: true};
fd.field('Add_x0020_Bidder').refresh();
}
Here is the result:
As a workaround I can get this to work:
function cascFilterBidder (addBidder) {
if (fd.field('Add_x0020_Bidder').value) {
var addBidderId = fd.field('Add_x0020_Bidder').value.LookupId;
fd.field('Add_x0020_Bidder_x0020_Contact').filter = 'CLCompany/Id eq ' + addBidderId + " and CLActive eq 'Active'";
fd.field('Add_x0020_Bidder_x0020_Contact').orderBy = {field: 'CLDispName', asc: true};
fd.field('Add_x0020_Bidder_x0020_Contact').refresh();
}
}
The problem is it hangs on to the filter when no one is selected in the 'Add_x0020_Bidder' lookup, which I can live with in the interim. I tried adding an else statement to remove the filter but it reacts in the same manner as it does when it is coded per the documentation:
if (fd.field('Add_x0020_Bidder').value) {
var addBidderId = fd.field('Add_x0020_Bidder').value.LookupId;
fd.field('Add_x0020_Bidder_x0020_Contact').filter = 'CLCompany/Id eq ' + addBidderId + " and CLActive eq 'Active'";
fd.field('Add_x0020_Bidder_x0020_Contact').orderBy = {field: 'CLDispName', asc: true};
fd.field('Add_x0020_Bidder_x0020_Contact').refresh();
} else {
var addBidderd = null;
fd.field('Add_x0020_Bidder_x0020_Contact').filter = 'CLCompany/Id eq ' + addBidderd + " and CLActive eq 'Active'";
fd.field('Add_x0020_Bidder_x0020_Contact').orderBy = {field: 'CLDispName', asc: true};
}