Ok. So what you’re really looking for is to code a customer table lookup, not a custom table relation! [:)]
I would start by creating a new function on the custom table to avoid coding it on the page. This new “LookupAvailableResources” could be something like this:
resource.reset;
Resource.setrange(Available,true);
IF PAGE.RUNMODAL(0, Resource) = Action::LookupOk then
validate("Mat. No.", Resource."No.");
But you can also apply the same table filter by setting the table relation manually on the Mat. No. control directly on the page. But you cannot do it via C/AL code.
Last question, if I put filter manually i have an error with French language version.
It translate the CONST “Yes” in french language.
Error message : Le filtre “Oui” n’est pas valide pour le champ Availble de la table Resource. “Oui” is not an option. “The existing options are: No, Yes”
But I actually come to think of a way where you can still do it and not “hardcode” the filter.
You could create another new field in your custom table. Call it “Availability Filter” and create it as a Boolean type Flow Filter field.
Then you can use this filter field in your table relation to the “Mat. No.” field so the relation instead will be Available=FIELD(Availability Filter).
If you have created the new flowfilter field, then all you need to do is to set this filter. And that you can set either in the OnOpenPage trigger or on the OnAfterGetRecord trigger. Simply by SETRANGE(“Availability Filter”,TRUE). Or it can be set manually by the user. The flow filter field will show up in the “Limit Totals” filter.
the filter doesn’t works when i put my RTC in french language. Before i had errors message if you remember, this message doesn’t appear but the filter doesn’t works