Lookup Filter Help

I am having no luck filtering a Lookup column. I have tried a number of different examples in the community with no luck returning results in some instances or the correct results in others.

I am looking up Contacts. I want to filter by a Company Name. The Company Name is a Single Line Text Column. The Company Name will be static because I just want to include contacts from my Company. The Contact Field I am looking up is also a Single Line Text Column.

I have included the Extra Field CLCompanyCopy in Forms, this is the internal name of the column I want to apply the filter on.

Here is the code I am using, which is returning results just not filtered result.

function filterSiteContact(){
    var v = 'MyCompany';
    fd.field('Site_x0020_Contact').filter = "CLCompanyCopy eq '" + v + "'";
    //alert(fd.field('Site_x0020_Contact').filter);
    fd.field('Site_x0020_Contact').widget.dataSource.read();
}

fd.field('Site_x0020_Contact').ready().then(filterSiteContact);

I have also tried this without the fd.field('Site_x0020_Contact').ready().then(filterSiteContact); and no function. This yields no results. I have verified the String matches what I am trying to filter.

My eventual goal is to filter by both company name and a status (which is a choice field), then also ordering the results by the last name column but since I cannot get this easy filter to work I am trying to simplify and work my way up!

Hello @cwalter2,

The code seems fine.

Do you get any errors in the browser console(F12)? Could you please share the screenshot, so I could troubleshoot the issue.

Here is the error I get.

I am having another issue with this same form.
I have included
window.fd = fd;
and the following code when I open a child form in Dialog:
fd.control('Inspections').dialogOptions = {
width: 1024,
height: 720
}
But the dialog is not opening properly, all the elements are passing through and I have verified 'Inspections' is correct.

Hello @cwalter2,

There is the error in the other part of your code and it breaks the code ran.

Please share the complete code that you are using. Thank you!

Finally figured it out. I did have an error that was something else all together. What I ended up having to do was add encodeURIComponent(v) and it started working. I assume the other error on my form may have been why the dialog wasn't working as well because I fixed both at the same time and all is well.

1 Like